[Tutor] file name change script
Sheila King
sheila@thinkspot.net
Sun, 24 Mar 2002 17:59:52 -0800
On 24 Mar 2002 20:55:01 -0500, jb <jboyko@sympatico.ca> wrote about
[Tutor] file name change script:
> What I'm trying to figure out, is how to write a python script which
> would do the following in the bash shell ...
>
> change all the existing file names in a directory to new file names
> which are made up of sequencial numbers,
>
> eg. <oldfilename_x.txt> to <001.txt>
> <oldfilename_y.txt> to <002.txt>
> <oldfilename_z.txt> to <003.txt>
> ...
>
> Any suggestions would be greatly appreciated
You can make a script that will do this on any platform that Python runs
on, making it portable. (Maybe you don't care about that right now, but it
is a plus of the Python language...)
Perhaps you want to check out the os module, which has many commands for
working with files, filenames and directory names and paths:
http://www.python.org/doc/current/lib/module-os.html
HTH,
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/