news 2026/5/16 4:27:06

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
【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)
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/13 12:03:59

花卉及病虫害检测数据集VOC+YOLO格式2199张44类别

数据集格式:Pascal VOC格式YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件)图片数量(jpg文件个数):2199标注数量(xml文件个数):2199标注数量(txt文件个数):2199标注类别…

作者头像 李华
网站建设 2026/5/5 10:22:55

如何用 unittest 写出高质量代码?

在 Python中 ,unittest 模块是进行单元测试的强大工具。无论你是初学者还是有经验的开发者,单元测试都是确保代码质量的重要一环。而 unittest 模块就是让这一过程变得简单、快捷的利器。 什么是单元测试? 在进入 unittest 模块之前&#x…

作者头像 李华
网站建设 2026/5/5 10:23:58

海水陆养如何实现远程监控与智慧管理

行业背景在传统水产养殖面临近海资源萎缩、环境监管趋严、养殖风险高的背景下,海水陆养作为一种新兴的工业化养殖模式,正逐步成为保障优质海产品供应、实现可持续发展的重要途径。该模式通过在陆地搭建可控的养殖环境(罐体、集装箱等&#xf…

作者头像 李华
网站建设 2026/5/4 15:43:12

N485QA柴油机飞轮壳设计

2.2 N485QA飞轮壳结构设计 2.21飞轮壳前端面孔设计: 根据柴油机拆卸实习可知,曲轴的后端面伸出曲轴箱外与飞轮配铰,根据测绘可知飞轮壳壳体直径为φ350mm;曲轴后端面直径为φ126.8 mm,故飞轮壳前端面孔设计尺寸应该为…

作者头像 李华
网站建设 2026/5/15 12:56:29

双碳目标下农田温室气体排放估算与模拟技术应用

农业是甲烷(CH4)、氧化亚氮(N2O)和二氧化碳(CO2)等温室气体的主要排放源,占全产业排放的13.5%。农田温室气体又以施肥产生的N2O和稻田生产产生的CH4为主,如何对农田温室气体进行有效…

作者头像 李华
网站建设 2026/5/3 22:52:40

机械手设计

1.1 机械手及其组成 1.1.1 什么是机械手 机械手是一种能模仿人手臂的某些动作功能,按固定程序抓取、搬运物件或操作工具的自动操作装置。它可代替人的繁重劳动以实现生产的机械化和自动化,能在有害环境下操作以保护人身安全,因而广泛应用于…

作者头像 李华