Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created May 18, 2009 05:40
Show Gist options
  • Save seungjin/113340 to your computer and use it in GitHub Desktop.
Save seungjin/113340 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# copy files into target directory with timestamp
import os
import sys
from datetime import date
print("USAGE: python cpHere.py /Users/seungjin/Desktop/a");
# get src_folder_path
if ( len(sys.argv) > 1 ):
src_folder_path = sys.argv[1]
else:
src_folder_path = "/Users/seungjin/Desktop/a"
# get destination_folder_path
#destination_folder_path = sys.argv[2]
destination_folder_path = "/Volumes/Vols/Vol4/newfolder/Pics"
print destination_folder_path
# get prefix, YYYYMMDD_
prefix = date.today().strftime("%Y%m%d")
# get src folder file list
file_list = os.listdir(src_folder_path)
# Copy with prefix
for i in file_list:
target_file = src_folder_path+"/"+i
destination_file = destination_folder_path+"/"+prefix+"_"+i
cmd = "cp " + target_file + " " + destination_file
print cmd
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment