I am looking for a free program that automatically removes all the useless hidden files from a selected USB drive.

The files I'm talking about are the ones like .Trashes, etc... (essentially all the ones that start with . (a period/full-stop).


  • free
  • runs on Windows 7 64 bit (and OSX 10.6.8 if possible)
  • 2
    for OS X, already inlcuded. The Terminal.app and remove the files with bash script. Or, use AppleScript or Automator.app workflow.
    – clt60
    Jul 18, 2014 at 21:51
  • 1
    What makes you think that every file starting with . 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, 2015 at 9:07
  • 1
    @Mawg You're right, but my use case was for removing files from a USB drive, and I'll never have any system files on my USB, therefore this will work for me. Anything starting with a period, to me, on my USB, is useless! Mar 10, 2015 at 17:18

2 Answers 2


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

    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

if __name__ == "__main__":
        folder_path = str(sys.argv[1])
        folder_path = "default_folder_path"

7zip can be more helpful. Although it is a compression tool there is an inbuilt explorer (far better than the Windows 7 one) in 7zip which can be used as another way to view/remove hidden files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.