news 2026/4/18 11:01: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/4/18 8:37:21

GetTickCount

有些业务中需要计算时间,比如:心跳包场景、业务代码运行时长 整理代码也学习其之间不同: GetTickCount()类函数:获取系统启动到当前的毫秒数,是单调递增的,不受系统时间修改影响 time(nullptr):获取1970/1/1到当前的时间戳(秒数),是utc时间,受系统时间影响 代码 #i…

作者头像 李华
网站建设 2026/4/18 8:46:50

IMFBS01现场接口模块

IMFBS01 现场接口模块是工业自动化系统中的信号转换与传递单元,主要用于连接控制系统与现场设备,实现各种输入输出信号的可靠接入与分发。主要功能说明:提供多通道输入/输出接口,用于采集或输出现场信号。支持数字量和模拟量信号的…

作者头像 李华
网站建设 2026/4/18 8:30:57

本站最全网络安全学习路线图(2026版详解版)

近期,大家在网上对于网络安全讨论比较多,想要学习的人也不少,但是需要学习哪些内容,按照什么顺序去学习呢?其实我们已经出国多版本的网络安全学习路线图,一直以来效果也比较不错,本次我们针对市…

作者头像 李华
网站建设 2026/4/17 18:52:37

Github Copilot使用指南

tab 自动补齐代码或者注释ctrl i 内联聊天根据你的要求生成代码agent能够使用执行命令行命令,但是Edit不能

作者头像 李华