2024年6月

adb pull /storage/sdcard0/Android/data/org.telegram.messenger/files/Telegram/ ./

先拖回来,再用python脚本分别放到子目录下。

import os
import shutil
import sys

def organize_files(directory):
    directory = os.path.normpath(directory)  # 标准化目录路径
    for filename in os.listdir(directory):
        filepath = os.path.join(directory, filename)
        print(filepath)
        if os.path.isfile(filepath):
            if filename.split('_')[0].isdigit():
                prefix = filename.split('_')[0]
                subdirectory = os.path.join(directory, prefix)
                if not os.path.exists(subdirectory):
                    os.makedirs(subdirectory)
                dst_file = os.path.join(subdirectory, filename)
                print(filepath+"|"+dst_file)
                #sys.exit()
                shutil.move(filepath, dst_file)

# 替换为你的目录路径
directory_path = 'D:/backup2/Telegram/Telegram Video'
organize_files(directory_path)