Omnimaga
General Discussion => Technology and Development => Computer Programming => Topic started by: Snake X on June 24, 2011, 01:31:19 pm
-
I have a request for a somewhat simple program in python. I want a program that can replace _ in file names with a space (these files are all in 1 folder so i can run the program in the same folder if that helps). I have several files in a folder with _'s that should be spaces but there are soo many that a program would be much better. Thanks.
-
/me was challenged!
import os
import sys
for i in os.listdir(sys.path[0]):
os.rename(i,i.replace("_", " "))
The script has to be placed in the folder. You run it and it changes all "_"'s in files to " "'s.
Also, even though the code sounds simple, it was not so simple :)
-
thanks so much, it worked :)
-
thanks so much, it worked :)
No problem, it's a pleasure :)