Skip to content

Instantly share code, notes, and snippets.

@ties
Created May 26, 2014 12:21
Show Gist options
  • Save ties/790aca60487e660e986d to your computer and use it in GitHub Desktop.
Save ties/790aca60487e660e986d to your computer and use it in GitHub Desktop.
import os, shutil, os.path
"""
Crudely move all "dot"/hidden files from the current directory to a target dir.
... saved me 8GB of disk space and a lot of manual filtering after restoring some hidden files to Desktop.
Of course I could delete the Desktop dir. 20/20 hindsight...
"""
src_dir = "/Users/<user>/Desktop"
target_dir = "/Users/<user>/Desktop/<tgt>"
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
for idx, cand in enumerate(os.listdir(src_dir)):
if (cand[0:1] == '.'):
print("{} | moving {}".format(idx, cand))
shutil.move(cand, target_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment