将文件从屏幕截图移动到不同的文件夹

Moving files from screenshots to a different folder

这是代码,它通过屏幕截图搜索并获取具有特定字符串的那些。

import os
import shutil
#from pathlib import Path


#'E:\Test'
#if src = 'path/to/file.txt'
#grabs = 'C:\Users\Gal\Videos\Captures'
#'C:\Users\Gal\Videos\Captures'


directory = ('C:\Users\Gal\Videos\Captures')
target = ('C:\zorko')
destination = 'zorko'


for filename in os.listdir(directory):
    data = str(filename)
    final = 'teorija' in data
    path = os.path.abspath(filename)
    if final is True:
        print('1')
        shutil.move(filename, target)

然而,当尝试使用 shutil 移动它们时,它显示此错误:

Traceback (most recent call last):
  File "C:\Users\Gal\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 788, in move
    os.rename(src, real_dst)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'T1A INF teorija _ Microsoft Teams 10_21_2020 10_39_27 AM.png' -> 'C:\zorko\T1A INF teorija _ Microsoft Teams 10_21_2020 10_39_27 AM.png'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Gal/PycharmProjects/pythonProject2/main.py", line 23, in <module>
    shutil.move(filename, target)
  File "C:\Users\Gal\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 802, in move
    copy_function(src, real_dst)
  File "C:\Users\Gal\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 432, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Users\Gal\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 261, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'T1A INF teorija _ Microsoft Teams 10_21_2020 10_39_27 AM.png'
import os
import shutil

directory = ('C:\Users\Gal\Videos\Captures')
target = ('C:\zorko')
destination = 'zorko'
for filename in os.listdir(directory):
    if 'teorija' in filename:
        shutil.move(os.path.join(directory, filename), os.path.join(target, filename))