python - 检查电话目录(电话到 Linux 的连接)
问题描述
我正在编写一个脚本,将我的手机摄像头拍摄的图像复制到我的 Linux 机器上的 Pictures 文件夹中。
import shutil
from os.path import isdir
source_directory = "mtp://SAMSUNG_SAMSUNG_Android_98897a384e484c5433/Phone/DCIM/Camera/"
destination_directory = "/home/lemons/Pictures/"
def main():
if isdir(source_directory): # If the phone is plugged in correctly
print("Phone is plugged in correctly.")
else:
print("Error: {0} not found! Please make sure the phone is plugged in.".format(source_directory))
if isdir(destination_directory): # Check if the target directory exists
print("Target directory is present.")
else:
print("Error: {0} not found!".format(destination_directory))
if __name__ == "__main__":
main()
问题是当我在文件资源管理器中查找源目录时,我正在处理不同的目录命名格式:mpt://[insert phone device name]/Phone/DCIM/Cmaera/"
. 当我运行脚本时,如果说找不到源目录。如何isdir()
在手机解锁时运行脚本时检查此目录是否存在?
解决方案
推荐阅读
- ssh - 如何在 gcloud vm 上修复 ssh
- javascript - 我可以在 ApexCharts 热图中进行缩放吗?
- javascript - 在下一行定义数组后,数组的值也没有显示,显示错误
- java - 如何在 Springboot 中创建假 FeignClient?
- wildcard - 作业完成后,snakemake 缺少输出异常
- powershell - 外壳 | 仅在每月的第一个星期四运行
- c - 将保存在数组中的十进制数转换为保存在数组中的二进制数,反之亦然
- ruby-on-rails - Rails group_by 自定义方法(Levenshtein 距离)
- c++ - 如何消除错误:pcl/memory.h:构建 c++ 文件时没有这样的文件或目录?
- python - YOLOv3 python如何在GUI中显示输出?