Message: 7
Date: Thu, 10 Apr 2008 01:46:49 +0100
From: "Alan Gauld" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Copy script
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
       reply-type=original

>>I don;t see how the input file relates to the pdf files?
>>Which part of the pdf file does the input numbers refer to?

Kent, I believe the text file contains the name of the text files the author
wants to copy
The problem with the Windows console commands is I don't believe they have
the ability to read files for input.

Que
Here is some code that should get you started.
I don't see the name of the destination directory in your email, so you will
have to edit the variable 'destpath' in the code below
Indenting is likely to get changed during posting, so be aware of that.

import shutil
import os

sourceDir=''

for line in open('input.txt'):
    if not sourceDir and ':' in line:
        sourceDir = line[line.find(':')-1:]

    if 'pdf' in line.lower():
        filename = line.split(' ')[-1]
        sourcePath = os.path.join(sourceDir, filename)
        shutil.copyfile(sourcePath, destPath)
        print'\nCopying %s' % sourcePath


print'\nCopy done'
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to