当前位置: 首页 > news >正文

【android】oppo手机拷贝视频文件

  • oppo 至今没有一个助手,

  • 有一个助手是升级系统的

  • 有一个connect实际上是做镜像手机屏幕的

  • 当然,也能监控文件变化

  • 对于我有一个camera文件夹2000个文件

  • 导致我每次不开着手机,导出文件到pc经常会断开连接。

  • 然后如果重新connect,会到处一堆xxx(1) 这样的文件

  • 完全没有什么 断点续传、文件存在检测这样的功能

  • 可见oppo 是没有以顾客为中心啊。

  • 插入usb传输文件后,

  • copilot 帮写了一个检测文件名是否存在,存在则复制到我的备份磁盘,不存在,那么跳过的代码:

dump_videos.py

  • D:\XTRANS\cuda\03-graph-db\04-cmkg\phone\dump_videos.py
importwin32com.clientimportosimporttimedeflist_and_copy_videos(device_name,path_components,dest_root=None):shell=win32com.client.Dispatch("Shell.Application")# 17 = ssfDRIVES (This PC / My Computer)computer=shell.NameSpace(17)# Destination setupdest_shell_folder=Noneifdest_root:ifnotos.path.exists(dest_root):try:os.makedirs(dest_root)exceptOSErrorase:print(f"Error creating destination directory '{dest_root}':{e}")return# Get Shell Folder for destinationdest_shell_folder=shell.NameSpace(dest_root)ifnotdest_shell_folder:print(f"Error: Could not get ShellFolder for '{dest_root}'")returnprint(f"Destination folder ready:{dest_root}")current_folder=None# 1. Find the device in "This PC"print(f"Searching for device:{device_name}in 'This PC'...")# Note: If executed in a non-interactive session, ensure Shell.Application is available.found_device=Falseforitemincomputer.Items():# Using simple Name match. Sometimes display name might vary slightly.ifitem.Name==device_name:current_folder=item.GetFolder found_device=Truebreakifnotfound_device:print(f"Error: Device '{device_name}' not found.")print("Available devices/drives (in 'This PC'):")foritemincomputer.Items():print(f" -{item.Name}")return# 2. Traverse the path componentsprint(f"Device found. Navigating path:{' -> '.join(path_components)}")forcomponentinpath_components:found=Falseitems=current_folder.Items()foriteminitems:ifitem.Name==component:# Check if it is a folder. Note: Some MTP folders might report weird types, but IsFolder works usually.ifitem.IsFolder:current_folder=item.GetFolder found=Truebreakifnotfound:print(f"Error: Folder '{component}' not found in '{current_folder.Title}'.")print("Available items in current folder:")foriteminitems:# Only printing folders to reduce noise, or first 20 itemsprint(f" -{item.Name}{'[Dir]'ifitem.IsFolderelse''}")returnprint(f"Target folder reached:{current_folder.Title}")# 3. Recursively list and copy videosoutput_file="video_list_3.txt"print(f"Scanning for videos (MOV, MP4, MKV, AVI, etc)...")ifdest_root:print(f"Syncing to{dest_root}")video_extensions=('.mov','.mp4','.m4v','.mkv','.webm','.avi','.3gp','.ts','.flv','.wmv','.asf')stats={'found':0,'copied':0,'skipped':0,'errors':0}found_videos_paths=[]defrecursive_scan(folder,relative_path):try:items=folder.Items()exceptExceptionase:print(f"Access denied or error reading folder{relative_path}:{e}")returnforiteminitems:try:ifitem.IsFolder:new_path=os.path.join(relative_path,item.Name)# print(f"Scanning: {new_path}")recursive_scan(item.GetFolder,new_path)else:name=item.Nameifname.lower().endswith(video_extensions):full_rel_path=os.path.join(relative_path,name)stats['found']+=1found_videos_paths.append(full_rel_path)ifdest_rootanddest_shell_folder:# Flattened unique check: check if filename exists in dest_root# (ignoring relative source path structure for the check, as requested "comparison with E:\...\files")target_path=os.path.join(dest_root,name)ifos.path.exists(target_path):print(f"[SKIP]{name}(already exists)")stats['skipped']+=1else:print(f"[COPY]{name}->{target_path}")try:# CopyHere flags:# 4 (no progress dialog) | 16 (yes to all) | 256 (simple progress)# Using 256 to show some Windows progress if it takes long, or 0 (default).# Since we are doing file by file, let's suppress UI if possible (4)# but MTP copy can be slow.dest_shell_folder.CopyHere(item,16)# 16 = Respond to "Yes to All" for any dialog box# Very crude wait mechanism because CopyHere is async# Waiting for file to appeartimeout=60# secondsstart_wait=time.time()whilenotos.path.exists(target_path):time.sleep(0.5)iftime.time()-start_wait>timeout:print(f"Warning: Timeout waiting for{name}to appear.")break# Optional: Check if size is growing? skipping for speed.# Just a small sleep to avoid flooding COMtime.sleep(0.5)ifos.path.exists(target_path):stats['copied']+=1else:stats['errors']+=1exceptExceptionascopy_err:print(f"Error copying{name}:{copy_err}")stats['errors']+=1exceptExceptionase:# Sometimes accessing properties of MTP items fails randomlyprint(f"Error processing item:{e}")recursive_scan(current_folder,"")withopen(output_file,"w",encoding="utf-8")asf:forvinfound_videos_paths:f.write(v+"\n")print("-"*40)print(f"Scan & Sync Complete.")print(f"Total Found:{stats['found']}")print(f"Copied:{stats['copied']}")print(f"Skipped:{stats['skipped']}")print(f"Errors:{stats['errors']}")print(f"List saved to{os.path.abspath(output_file)}")if__name__=="__main__":# Required: pip install pywin32# Phone NameDEVICE_NAME="OPPO Find X8s"# Source Path on Phone (MTP uses Names not drive letters)PATH_PARTS=["内部共享存储空间","DCIM","Camera"]# Target Directory on PC# User requested: E:\20260127-视频TARGET_DIR=r"E:\20260127-视频"list_and_copy_videos(DEVICE_NAME,PATH_PARTS,dest_root=TARGET_DIR)
http://www.jsqmd.com/news/312830/

相关文章:

  • 互联网大厂Java求职面试实战:微服务、缓存与AI技术全栈问答解析
  • 2026年护理床垫品牌推荐与排名:基于10大核心指标解析
  • 2026年护理床垫品牌推荐与评测:聚焦智能健康管理,解决舒适与安全核心痛点
  • 组合数学浅析
  • 如何为不同健康阶段选护理床?2026年品牌推荐与评价,直击兼容与操作痛点
  • 玻璃转子流量计常见问题解答(2026最新专家版)
  • 2026年家用护理床品牌推荐:权威评测揭示五大品牌综合实力排名
  • 2026年护理床垫品牌推荐:专业评测与权威排名解析
  • Linux中使用find命令搜索文件
  • 联想浏览器下载安装教程(2026 最新版)
  • 2026年家用护理床品牌推荐:深度评测与选购权威指南
  • 2026年雷克沙存储卡深度分析:长期可靠性评测,针对专业与户外场景核心痛点
  • 2026年雷克沙存储卡专业解读:聚焦高速读写与耐用性痛点的场景化推荐
  • 获国家级权威认可!itc保伦股份智慧城市项目入选“2025全国企业数字中国建设优秀应用案例”
  • 2026年家用护理床品牌推荐:居家照护场景深度评测与权威排名解析
  • wpf程序文件更改项目名称
  • 2026年大疆无人机存储卡推荐:基于多机型实测排名,针对文件安全与写入稳定性痛点
  • 小程序毕设项目:基于springboot+Android的高校食堂点餐配送系统小程序(源码+文档,讲解、调试运行,定制等)
  • day11 补
  • 2026年大疆无人机存储卡推荐:基于多机型兼容性评价,针对视频中断与文件损坏痛点精准指南
  • 东莞高压电力维保多少钱,如何选择合适的?
  • 说说深圳口碑好的FLYBROW飞艇汽车用品哪家强
  • TPE汽车脚垫和PVC脚垫对比,哪个品牌的汽车脚垫口碑更好
  • 2026年值得推荐的婚庆篷房布供应商选购指南及性价比排名
  • 2026年江苏拉簧厂家综合评估:谁更值得信赖?
  • 2026年成都营销推广公司推荐与排名:基于多场景实战评测,解决增长与效果验证痛点
  • 2026年肥料挤压造粒机厂家推荐:郑州市天宇机械有限公司,多型号设备助力肥料生产升级
  • 2026年成都营销推广公司推荐:多场景深度评测,针对预算与效果痛点提供精准排名
  • 2026年医院门专业厂家推荐:山东森工门业防火/洁净/电动/树脂/金属医院门全系解决方案