[Tutor] Batch file copy script
Kent Johnson
kent37 at tds.net
Mon Aug 6 13:48:28 CEST 2007
Majid wrote:
> Here is a possible logic for the script:
>
> 1. Open the list (C:\py\list.txt).
> 2. Until the end of the file
> 3. Read a line from list.txt (e.g. '/dists/dapper/Release.gpg')
> 4. Change forward slashes to back slashes (e.g.
> '\dists\dapper\Release.gpg')
> 5. Add 'C:\source' to the string (e.g.
> 'C:\source\dists\dapper\Release.gpg')
> 6. If the file exists in the source folder
> 7. Copy the file from the source frolder to the target folder
> (e.g. copy C:\source\dists\dapper\Release.gpg to
> D:\target\dists\dapper\Release.gpg)
> 8. Else
> 9. Add the name of the missing file to missings.txt
> 10. End of loop
This would be a good first Python project. The actual script will be
almost line-for-line the same as your outline. There are many good
tutorials here:
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
You need to learn about lists and files, that's it. The shutil module
has a copyfile() function that will do the actual copying.
Kent
More information about the Tutor
mailing list