Author Topic: (somewhat) simple program request  (Read 2267 times)

0 Members and 1 Guest are viewing this topic.

Offline Snake X

  • Ancient Veteran
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 810
  • Rating: +33/-8
    • View Profile
(somewhat) simple program request
« 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.
Loved this place, still the best producers of power metal, and sparked my dreams of coding.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: (somewhat) simple program request
« Reply #1 on: June 24, 2011, 01:46:10 pm »
* Scout was challenged!

Code: [Select]
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 :)

Offline Snake X

  • Ancient Veteran
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 810
  • Rating: +33/-8
    • View Profile
Re: (somewhat) simple program request
« Reply #2 on: June 24, 2011, 02:00:24 pm »
thanks so much, it worked :)
Loved this place, still the best producers of power metal, and sparked my dreams of coding.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: (somewhat) simple program request
« Reply #3 on: June 24, 2011, 02:14:25 pm »
thanks so much, it worked :)

No problem, it's a pleasure :)