|
Snake X
|
 |
« on: 24 June, 2011, 19:31:19 » |
0
|
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.
|
|
|
|
|
Logged
|
There's a Zombie for that™
|
|
|
|
Munchor
|
 |
« Reply #1 on: 24 June, 2011, 19:46:10 » |
+1
|
* Scout was challenged! 1 2 3 4 5 6
| 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 
|
|
|
|
|
Logged
|
|
|
|
|
Snake X
|
 |
« Reply #2 on: 24 June, 2011, 20:00:24 » |
0
|
thanks so much, it worked 
|
|
|
|
|
Logged
|
There's a Zombie for that™
|
|
|
|
Munchor
|
 |
« Reply #3 on: 24 June, 2011, 20:14:25 » |
0
|
thanks so much, it worked  No problem, it's a pleasure 
|
|
|
|
|
Logged
|
|
|
|
|