help with counter

Laura Creighton lac at strakt.com
Tue Jan 7 03:57:05 EST 2003


hint:
If I gave you a list of filenames, and told you to drop every
third filename, could you do it?

If I gave you a list of filenames and told you to rename them to
newname.x.txt, newname.x+1.txt ... could you do that?

Laura Creighton

> I must have been looking at this problem for to  long, but I need some
> help because I am stuck.
> 
> I have a series of files on disk   file.01.txt, file.02.txt ...
> what I am trying to do is rename all the files a new name but also not
> renaming a few files but maintaining the number sequence
> 
> for example 
> 
> #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
> 
> 
> should produce 
> 
> file.01.txt     	newfile.01.txt
> file.02.txt	newfile.02.txt
> file.03.txt	
> file.04.txt	newfile.03.txt
> file.05.txt	newfile.04.txt
> file.06.txt	newfile.05.txt
> file.07.txt	newfile.06.txt
> file.08.txt	
> file.09.txt	newfile.07.txt
> file.10.txt ...	newfile.08.txt...
> 
> the filename changes the amount changes and the file to be dropped
> changes.
> 
> For some reason I can't put my head around this problem.  Any help
> would be appreciated.
> 
> BC
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list