Skip to content

Instantly share code, notes, and snippets.

@kamalbanga
Last active August 29, 2015 14:03
Show Gist options
  • Save kamalbanga/32d31041cec45b23904e to your computer and use it in GitHub Desktop.
Save kamalbanga/32d31041cec45b23904e to your computer and use it in GitHub Desktop.
Copy a file into multiple files in Python.
import os, sys, shutil
DUP = 10
file = sys.argv[1]
path, fileName = os.path.split(file)
file_name, file_extension = os.path.splitext(fileName)
for i in range(1, DUP+1):
shutil.copyfile(file,path+'/'+file_name+'_'+str(i)+file_extension)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment