Skip to content

Instantly share code, notes, and snippets.

@funwarioisii
Created October 8, 2017 07:13
Show Gist options
  • Save funwarioisii/f3ff8c72f09919999ac4df5b873953ee to your computer and use it in GitHub Desktop.
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''
# 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)
@funwarioisii
Copy link
Author

funwarioisii commented May 18, 2018

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