line.strip() for line in file: => line will contain '\n' at the end of the string.
Andreas Am Montag, den 14.04.2008, 00:08 -0700 schrieb Que Prime: > > This is what I came up with after writing it out and reading the > corresponding functions. I feel I'm close but something is still > awry. > > > #file copy based on input file containing filenames to be copied > > ############################## > import os > import shutil > > os.chdir('c:\\test') > infile = open("input.txt","r") > > for line in infile: > shutil.copy(line, 'outfolder') > #print line 'copied' > infile.close() > > ############################# > > ---------- Forwarded message ---------- > From: Alan Gauld <[EMAIL PROTECTED]> > Date: Sat, Apr 12, 2008 at 5:15 AM > Subject: Re: [Tutor] Simple copy script > To: tutor@python.org > > > "Que Prime" <[EMAIL PROTECTED]> wrote > > > > I'm trying to copy files from one directory to another based on an > > input txt > > file containing the filename. > > > > Source directory = C:\test > > Destination directory = C:\output > > > > input.txt looks like: > > > > 12345.pdf > > 12344.pdf > > > Try writing what you want to do in structured English first > > Open the file input.txt > For each line in input.txt : > copy the named file from source to destination > Close the file input.txt > > Now can you write that ion Python? (You may want to check > the shutil module for copying the files) > > If you can';t get it to work send us your code and any error > messages you get. > > You will find more detailed info in the Using the OS > topic of my tutor. > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor