[Tutor] create a copying tool
Jos Kerc
joskerc at gmail.com
Tue May 19 20:52:13 CEST 2015
Hi,
see comments below:
On Tue, May 19, 2015 at 2:20 PM, Remco <learningpython at hofs-bibo.nl> wrote:
> Hello,
<snip>
> import os
> import shutil
>
> target_dir = r'D:\target\'
> source_dir = r'D:\source\'
> source_file = r'D:\source\list.txt'
you are not using this...
> missing_files = open("missings.txt","w")
>
> for line in open('list.txt'):
> source_file = os.path.normpath(source_dir +line)
> target_file = os.path.normpath(target_dir +line)
> if os.path.exists(target_file):
don't you want to check if the source file is existing?
> shutil.copyfile(source_file,target_file)
> else:
> missing_files.write(line)
> missing_files.close()
> Can someone help my fixing my problem.
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
HTH,
More information about the Tutor
mailing list