"python listdir"에 해당되는 글 - 1건
Post
import os
file_path = '.\\pic'
file_names = os.listdir(file_path)
file_new_name = "사진이름변경"
i = 1
for name in file_names:
src = os.path.join(file_path, name)
dst = file_new_name + str(i) + '.jpg'
dst = os.path.join(file_path, dst)
os.rename(src, dst)
i += 1
python 폴더 내 파일 이름 변경
간단한 예제.
1) cmd 창을 켜고 해당 python 코드가 있는 폴더로 이동
2) py python파일이름.py
이렇게 실행하면 된다.
파일이름+숫자.....로 생성된다.
'이전게시판 > Python' 카테고리의 다른 글
파이썬 한글 글자수 체크 및 특정 단어 갯수 찾기 (0) | 2025.03.30 |
---|---|
inconsistent use of tabs and spaces in indentation in Python (0) | 2024.04.18 |
ModuleNotFoundError: No module named 'pandas' 아나콘다가 깔려 있을 때 해결법 (0) | 2024.01.27 |
Python 크롤링 리스트 출력 (0) | 2023.04.10 |