Programming/python
Python으로 파일 제목만 바꾸고 여러개 복사하기해서 생성하기
YAWP
2024. 7. 10. 16:26
728x90
반응형
매우 매우 매우 X 10000000000000000000000000000000000000000000000000000000000000^1000000000
귀찮은 설문조사를 해야하는데 아무리 봐도 그냥 대충 체크하고 단순 작업으로 해당 주차의 파일을 복사하고 생성하기만 하면 되는 것 같아 그냥 파이썬으로 코드를 짜서 해보았다.
전체 코드는 아래와 같다.
import shutil
for i in range(1,15):
for j in range(1, 2):
from_file_path = "C:/Users/YAWP/Desktop/test/{}주차_{}차시.hwp".format(i,j)
to_file_path = "C:/Users/YAWP/Desktop/test/{}주차_{}차시.hwp".format(i,j+1)
shutil.copyfile(from_file_path, to_file_path)
to_file_path = "C:/Users/YAWP/Desktop/test/{}주차_{}차시.hwp".format(i+1,j)
shutil.copyfile(from_file_path, to_file_path)
코드 돌리기 전
코드 돌리면
일일이 파일 복사 생성 복사 생성 복사 생성의 귀찮은 작업을 하지 않고 바로 ㄱㄱ 할 수 있음 개꿀
728x90
반응형