help with counter

Brad Hards bhards at bigpond.net.au
Tue Jan 7 04:09:52 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 7 Jan 2003 07:20, Bill Carter wrote:
> #sample command line
> pyrename.py file.01.txt file.400.txt  3 newfile.01.txt
>
> # breakdown
> script name / filename of first file / last filename / drop every 3rd
> file / new filename and start number
I won't code it for you (partly because the problem is underspecified), but as 
a general suggestion, try to loop through the various file names. Inside the 
loop, increment a counter. Also within the loop, test the value of the 
counter against the drop count (using a modulo operator), and if appropriate, 
call os.rename(). I think this is less than 10 lines of code.

Brad
- -- 
http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+GplgW6pHgIdAuOMRAruYAJ9xhe1GiLtRnXD0YXoPbhKpYEdbXgCfaQ4A
2x5yUQ+rZvMQBduN6QXYBuk=
=QpAX
-----END PGP SIGNATURE-----






More information about the Python-list mailing list