+ 1

Remove characters from file names

I am trying to remove spaces and parentheses from files with a specific extension. can anyone give me a real world example of python code to accomplish this?

14th Nov 2016, 3:40 PM
Alicia Evans-Morley
Alicia Evans-Morley - avatar
3 Antworten
+ 1
A small workaround till a good solution : 1. Read the file contents 2. Save the filename in a variable (if possible) 3. Trim the string (in Java you have the String.trim() method) 4. Create a new New file with the name of the trimmed variable and save the saved content in it 5. Delete original file Hope this helps
14th Nov 2016, 6:24 PM
Arsal Ali
Arsal Ali - avatar
0
I need to do it for a large number of files
14th Nov 2016, 6:30 PM
Alicia Evans-Morley
Alicia Evans-Morley - avatar
0
In that case maybe in A loop. But then this is not a good solutions because it would take too much time
14th Nov 2016, 6:33 PM
Arsal Ali
Arsal Ali - avatar