还有其他类似问题,但我找不到我的特殊情况的答案。我希望有一些相当聪明的人能够提供帮助?我正在使用shutil.copy2进行复制,因此一切都应该在硬盘驱动器中进行,否则可以正常工作。一个区别是,现在我通过其他一些功能的powershell来运行它。为什么在以下代码中获得对newnew_path的Errno13权限被拒绝?:
def move_fused_tiffs(dir_path):
abs_dirpath = os.path.abspath(dir_path)
print(abs_dirpath)
import shutil
for folderName, subfolders, filenames in os.walk(dir_path):
for filename in filenames:
if filename.endswith('used.tiff'):
print(filename)
full_path = os.path.join(folderName, filename)
prefix = os.path.basename(folderName)
StitchingPath1 = os.path.dirname(folderName)
print(StitchingPath1)
StitchingPath2 = os.path.dirname(StitchingPath1)
print(StitchingPath2)
FU_TIFFS = "\FUSED_TIFFS"
new_name = os.path.join(StitchingPath2, FU_TIFFS)
print(new_name)
newnew_name = os.path.join(new_name, prefix)
print(newnew_name)
shutil.copy2(full_path, newnew_name)
print("copy successful")