Created
May 18, 2009 05:40
-
-
Save seungjin/113340 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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