Created
October 8, 2017 07:13
-
-
Save funwarioisii/f3ff8c72f09919999ac4df5b873953ee to your computer and use it in GitHub Desktop.
This script is for delete unuseful Mac file(e.g. '.DS_Store' , '._hoge.jpg''
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
# coding=utf-8 | |
import os | |
def deleter(file_path): | |
""" | |
指定したディレクトリの中でMacの邪魔ファイルを消す | |
:param file_path: | |
:return: | |
""" | |
for item in os.listdir(file_path): | |
item = file_path + "/" + item | |
if not os.path.isdir(item): | |
if '._' in item or 'DS_Store' in item: | |
print('delete this item :' + item) | |
os.remove(item) | |
else: | |
deleter(item) | |
if __name__ == '__main__': | |
print('PLEASE TEST MINIMUM STRUCTURE') | |
print("if you have any losses, I cannot take responsibility.") | |
print("put directory name you want to clean up") | |
file_path = raw_input('>>> ') | |
deleter(file_path) |
Declaring as following, it is working well everywhere.
function deleter(){python ~/path/to/deleter.py}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tested on
It works well.