[Python]파일명 바꾸기

예섬이를 위해 간단히 짜본 파이썬 스크립트.
문제는 엠파스에서 탭이 제대로 안붙는구나 ;;
[요구사항]
특정 폴더를 선택하여, 해당 폴더가 가지고 있는 파일들의 이름 앞에 특정 문자열을 붙일 수 있어야 한다.
import os, time, string
import Tkinter
from tkFileDialog import askdirectory
myPath = askdirectory(title="select directory", mustexist=1)
if not myPath:
print "cancelled"
else:
print "selected", myPath
#myPath = raw_input("Enter the path you want to change filename : ");
suffix = raw_input("Input suffix you want : ");
for f in os.listdir(myPath):
tempPath = os.path.join(myPath, f)
tempPath2 = os.path.join(myPath, suffix + f)
if not os.path.isdir(tempPath):
os.rename(tempPath, tempPath2)
raw_input("finished")

replace.py

by 소혼 | 2008/12/28 20:04 | ┣프로그래밍 일반 | 트랙백 | 덧글(2)

트랙백 주소 : http://mysprit.egloos.com/tb/5845075
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Commented by 소혼 at 2008/12/28 21:43
Commented by 소혼 at 2008/12/28 22:29

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶