Skip to content

Instantly share code, notes, and snippets.

@perifer
Created November 3, 2011 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/1336127 to your computer and use it in GitHub Desktop.
Save perifer/1336127 to your computer and use it in GitHub Desktop.
Script to move download/recreated features to correct folder. Perfect as an Automator Folder Action.
import sys
import os
import os.path
import re
import subprocess
import shutil
destination = "/Users/USER/Projects/SITE/public_html/sites/all/modules/feauters"
module = re.compile(r".*/(PREFIX)[^/]*.tar$")
for f in sys.argv[1:]:
match = module.match(f)
if match:
module_dir = os.path.join(destination, match.group(1))
if os.path.exists(module_dir):
shutil.rmtree(module_dir)
subprocess.call(["tar", "xf", f, "-C", destination])
os.remove(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment