我正在写一个Python脚本,它有2个文件夹,一个是source_folder另一个是destination_folder,我想要实现的是从源文件夹我应该能够移动x个文件到destination_folder,其中X是从数据库获取数据的变量,所以例如我想要x = 10,它应该在x秒或分钟后的给定时间点只复制10个文件,我可以移动,但不是成批的
这是我代码,
import os
import shutil
source = 'callfiles/processed/'
destination = 'callfiles/created/'
# gather all files
allfiles = os.listdir(source)
# iterate on all files to move them to destination folder
for f in allfiles:
src_path = os.path.join(source, f)
dst_path = os.path.join(destination, f)
shutil.move(src_path, dst_path)
字符串
关于CJ
1条答案
按热度按时间pcww981p1#
字符串