Why is it so wrong of me to want to copy files in the following way? (in iPython)
for item in to_save:
....: try:
....: folder = os.path.split(item)[0]
....: os.makedirs("backup_folder/" + folder)
....: except:
....: pass
....: !cp $item folder/$item
This would be ideal for me.
[The issue I'm complaining about is that when you copy a file in Unix, the target location must already exist for the file. Python's os.makedirs() makes intermediary folders (unlike the similar os.makedir())--but, in neither Python nor Bash can I find a function that copies, while making those intermediary folders. I can't imagine a danger in this, but seem to want to do it while backing up, all of the time.]
Wednesday, July 28, 2010
Subscribe to:
Posts (Atom)
