Skip to content

Instantly share code, notes, and snippets.

@tatesuke
Created January 24, 2022 06:57
Show Gist options
  • Save tatesuke/c12b277bed5937d93a10adcb3f1e6177 to your computer and use it in GitHub Desktop.
Save tatesuke/c12b277bed5937d93a10adcb3f1e6177 to your computer and use it in GitHub Desktop.
AppleDoubleなどを削除するPythonスクリプト(遅め)
import os
import shutil
ROOT_DIR = "N:/documents"
def remove(path):
if os.path.isfile(path):
os.remove(path)
else:
shutil.rmtree(path)
print(f"Deleted: {path}")
for curDir, _, files in os.walk(ROOT_DIR): # 全ファイル操作するので遅い。
if curDir.endswith(".AppleDouble") or curDir.endswith(".picasaoriginals"):
remove(curDir)
continue
for file in files:
if (file == ".DS_Store") or (file == "._.DS_Store") or (file == ".picasa.ini"):
filePath = os.path.join(curDir, file)
remove(filePath)
print(f"scaned: {curDir}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment