views:

42

answers:

1

I have a directory which contains subdirectories which contain files. All the file names have a prefix which I want to eliminate. The prefix is not exactly the same among all the files, but I have a regular expression that represents exactly the language of these prefixes. I'm trying to write a script in Python to change the name of each file to its name without the prefix. I don't know yet how to "play" with files in Python (know just basic i/o operations). Could you help a little?

I use Python 3.

+3  A: 

You might find these functions useful:

You might want to look at using glob.glob if the prefixes you are trying to match are supported by the language glob uses (it doesn't support full regular expressions, but it does allow some wildcards).

Mark Byers
Python is great. Thanks
snakile