You can use the following Python script to remove every file and folder starting with .
. Install Python, cd
to the root of your USB key and type python hidden_file_remover.py
:
# Save this script as hidden_file_remover.py in the root of your USB key:
import os
import shutil
import sys
def main(folder_path):
for dirpath, dirnames, filenames in os.walk(folder_path):
for dirname in [d for d in dirnames if (d.startswith("."))]:
dirfullpath = os.path.join(dirpath, dirname)
print dirfullpath
try:
shutil.rmtree(dirfullpath)
except:
pass
for dirpath, dirnames, filenames in os.walk(folder_path):
for filename in [f for f in filenames if (f.startswith("."))]:
filepath = os.path.join(dirpath, filename)
print filepath
os.remove(filepath)
if __name__ == "__main__":
try:
folder_path = str(sys.argv[1])
except:
folder_path = "default_folder_path"
main(folder_path)
Terminal.app
and remove the files withbash
script. Or, useAppleScript
orAutomator.app
workflow. – jm666 Jul 18 '14 at 21:51.
is "useless". Some may be, but the origin of this naming is with Unix, where files which were important to system stability were so named. They wouldn't show up on a normal directory listing so that well meaning newbies wouldn't "tidy" them and destabilize the system. You might want to rethink a blanket approach to such files. – Mawg Mar 10 '15 at 9:07