May-01-2017, 08:38 AM
Hi guys,
I am pretty new to program, I have written a program that copies files from one directory to other, issue is not in that. Issue is with the print statement, python not able to pick the print statement and execute it. Happy if solved
I am pretty new to program, I have written a program that copies files from one directory to other, issue is not in that. Issue is with the print statement, python not able to pick the print statement and execute it. Happy if solved
import sys import os import shutil args = sys.argv[1:] if not args: print("Type Destnination and source file") sys.exit(1) Dest_dir = args[0] Source_dir = args[1] print("hello\n") filenames = os.listdir(Source_dir) def copy_to(abs_path,Dest_dir): if not os.path.exists(Dest_dir): os.mkdir(Dest_dir) shutil.copy(abs_path,Dest_dir) for fname in filenames: file_path = os.path.join(Source_dir,fname) abs_path = os.path.abspath(file_path) copy_to(abs_path,Dest_dir)