Feb-27-2018, 07:19 AM
(This post was last modified: Feb-27-2018, 08:14 AM by Prince_Bhatia.)
hi,
i want to move several file mentioned in csv to another folder path which is mentioned in code
i have several pdf's mentioned in the attached csv file, in csv file there is one column with the filename including it's path....but when i try to run this it says
i want to move several file mentioned in csv to another folder path which is mentioned in code
i have several pdf's mentioned in the attached csv file, in csv file there is one column with the filename including it's path....but when i try to run this it says
Error:File "C:\Users\prince.bhatia\Desktop\install\copying_module.py", line 10
"filename", "D:\maharera", "D:\maharera\copy" = argv[1:]
^
SyntaxError: can't assign to literal
[Finished in 0.226s]
below is my code:import shutil import os import csv import sys dataobj = {} filename = "maharera.csv" def main(argv): filename, "D:\maharera", "D:\maharera\copy" = argv[1:] with open(filename, "rb")as csvfile: reader = csv.reader(csvfile) for row in reader: filename = row[0] filepath = row[1] if filename.startswith("D:\maharera"): filename = filename[len(existing_path_prefix):] newfile = os.path.join("D:\maharera\copy", filepath) print ('Copying %s to %s...' % filename, new_filename), shutil.copy(filename, new_filename) if __main__ == "__main__": main(sys.argv) #source = os.listdir("D:\maharera") #print(source) #destination = "D:\maharera\copy" #for files in source: # if files.endswith(".pdf"): # shutil.copyfile(files, destination)can anyone guide me in right direction since i have 15000 pdf out of which in files i have mentioned 501 which needed to move to another folder
Attached Files