我正在尝试将名为“备份”的本地文件夹中的“.mp4”格式文件复制到另一个目录/media/c1
。为此,我尝试了下面的python代码。
import shutil
fileList = os.listdir('/opt/backup/')
for f in fileList:
try:
flocation = '/opt/backup/' + f
fpath = '/media/c1/' + f
shutil.copy2(flocation, fpath)
except IOError:
print("IOERROR")
运行此脚本时,会抛出错误。
The file path is :/media/c1/1027.mp4
Traceback (most recent call last):
File "./test.py", line 33, in <module>
shutil.copy2(flocation, fpath)
File "/usr/lib/python2.6/shutil.py", line 100, in copy2
copystat(src, dst)
File "/usr/lib/python2.6/shutil.py", line 73, in copystat
os.utime(dst, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/media/c1/1027.mp4'
我需要复制位于备份文件夹中的所有媒体文件并将其粘贴到/media/c1/
目录中。