0
내 다운로드를 정렬하는 프로그램을 작성하려고합니다.파일 정렬 스크립트를 만들 때 오류가 발생했습니다.
Traceback (most recent call last):
File "/usr/lib/python3.5/shutil.py", line 538, in move
os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory:'UntitledDocument.txt' -> 'Downloads/TxtFiles/UntitledDocument.txt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nicholas/Python/DownloadSorter.py", line 19, in <module>
shutil.move(file, folders[fileType])
File "/usr/lib/python3.5/shutil.py", line 552, in move
copy_function(src, real_dst)
File "/usr/lib/python3.5/shutil.py", line 251, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.5/shutil.py", line 114, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'UntitledDocument.txt'
이것은 코드입니다 : 나는 그것을 실행하려고하면 그러나,이 얻을! # 문제가 있다고는/usr/빈/python3 수입 OS 수입
folders = {
'.tar.gz': 'Downloads/TarFiles',
'.deb': 'Downloads/DebFiles',
'.iso': 'Downloads/IsoFiles',
'.txt': 'Downloads/TxtFiles',
'.exe': 'Downloads/ExeFiles',
'.mp3': 'Videos',
'.wav': 'Music'
}
os.chdir('/home/nicholas/')
for file in os.listdir('Downloads'):
for fileType in folders.keys():
if file.endswith(fileType):
shutil.move(file, folders[fileType])
... 아직 대상 디렉토리가 실제로 존재한다고 가정. – tripleee
당신 말이 맞아요. 그러나 우리는 한 번에 하나의 오류를 다루고 있습니다 :) – table