安卓手机在读取U盘时会自动创建Android,Sounds等文件夹,弹出U盘后,这些文件夹本身可以删除。但是这些文件夹数量比较多,假如U盘根目录下的文件夹又比较多,每次手动删除就会很麻烦,且有误删的风险。
这个python脚本,可以实现自动删除这些文件夹:
⚠注意:由于包含删除文件及文件夹的破坏性操作,请评估风险后慎重操作。推荐在使用此脚本前先在新建的文件夹下测试一遍,且在第一次操作前先做好备份。
"""
After opening a udisk on android mobile device,\n
system would auto create several useless files and directories.\n
This python script could help clean up your udisk.\n
---
REMIND THIS:\n
Make sure the fileames of your own files&dirs are stored in the set 'verified_items'.\n
This script would delete all files&dirs except those included in 'verified_items'\n
Think twice before you run this script.
"""
import os
import shutil
config_file = "ignore.config" # path of config file that stores verified files&dirs
verified_items = {os.path.basename(__file__), config_file, "System Volume