기타 snippet
2021. 4. 20. 20:26
path내의 파일명 수정하기
""" Change filename in the given directory """ import os from os.path import isfile, join # Getting filenames # https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory #mypath = "C:\\Users\\Park\\Desktop\\PS\\SWExpertAcademy\\" mypath = r'C:\Users\Park\Desktop\PS\SWExpertAcademy' onlyfiles = [f for f in os.listdir(mypath) if isfile(join(mypath, f))] # get only filenames, not directories # Changing filename for filename in onlyfiles: #print(type(filename), filename) os.rename(mypath + "\\" + filename, mypath + "\\" + '0' + filename)
'<언어> > [Python]' 카테고리의 다른 글
데코레이터 + @lru_cache 데코레이터를 활용한 DP 캐싱 (0) | 2021.06.03 |
---|---|
[Python 심화] 이터레이터와 제너레이터 (0) | 2021.05.11 |
[Python] Input / Output (0) | 2020.12.26 |
[Python] Asterisk (*) 용도 (0) | 2020.09.01 |
[Python] String (0) | 2020.09.01 |