Created
January 24, 2022 06:57
-
-
Save tatesuke/c12b277bed5937d93a10adcb3f1e6177 to your computer and use it in GitHub Desktop.
AppleDoubleなどを削除するPythonスクリプト(遅め)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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