news 2026/7/20 22:41:38

【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/7/17 22:44:46

Linux驱动probe函数全解析:以蜂鸣器驱动为例,吃透初始化流程与规范

Linux驱动probe函数全解析:以蜂鸣器驱动为例,吃透初始化流程与规范 probe函数是Linux platform驱动的“灵魂入口”——当内核完成驱动与设备树/平台设备的匹配后,会调用probe函数完成驱动的核心初始化。本文以蜂鸣器驱动的probe函数为例&…

作者头像 李华
网站建设 2026/7/17 20:20:42

AI人工智能如何正确入行(小白程序员必收藏)

到底做什么,才算真正入行AI? 这个话题我在之前的分享中多次提及,今天结合工业界实际场景再系统梳理一遍:在企业中直接落地AI技术的岗位,核心可分为三大类——算法类、工程类、数据类。 当下网络上,无论是…

作者头像 李华
网站建设 2026/7/17 11:55:27

深入浅出 CAS:从 CPU 指令到 Java 17 原子类实战

这篇文章会用 Java 17 的视角,把 CAS 从底层原理到实际落地系统地讲清楚。 目标只有一个:看完这一篇,你对 CAS 的理解不再停留在“有三个参数 V/E/N”这种记忆层面,而是能从 CPU 指令一路推演到 Java 代码,再对框架源…

作者头像 李华
网站建设 2026/7/17 5:16:24

Thinkphp和Laravel基于Web的课程设计选题管理系统

目录ThinkPHP与Laravel框架的课程设计选题管理系统摘要项目开发技术介绍PHP核心代码部分展示系统结论源码获取/同行可拿货,招校园代理ThinkPHP与Laravel框架的课程设计选题管理系统摘要 基于ThinkPHP的选题管理系统 ThinkPHP作为国内流行的PHP框架,适合快速开发中小…

作者头像 李华
网站建设 2026/7/17 14:28:09

【收藏不迷路】大模型学习进阶篇:避开误区,从实战到落地全攻略

随着大模型技术的普及,越来越多程序员和AI小白投身其中,但不少人陷入“学了就忘”“实战卡壳”“落地无门”的困境。相较于基础入门,掌握科学的学习方法、精准避开技术坑点、聚焦场景落地,才是快速吃透大模型的关键。本文基于实战…

作者头像 李华
网站建设 2026/7/17 4:39:46

飞机起落架减震系统

1.2飞机起落架的布置形式 起落架的布置形式是指飞机起落架支柱(支点)的数目和其相对于飞机重心的布置特点。目前,飞机上通常采用四种起落架形式: 图1.1 后三点式起落架 后三点式起落架:这种起落架有一个尾支柱和两个主起落架。并且飞机的重…

作者头像 李华