2

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.

1 Answer 1

4

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.