python - os.rename 移动文件,然后在 2 秒后撤消 - Google Drive?
问题描述
如果我在普通目录中运行它,它将起作用。使用 shutil.move 具有相同的结果。
from os import listdir, rename
from os.path import getmtime, isfile
for x in match_list:
file_location = f'{f}\\{x[0]}'
file_destination = f'{f}{old_dir}\\{x[0]}'
if isfile(file_location):
if isfile(file_destination):
dot_loc = file_destination.rfind('.')
file_destination = f'{file_destination[:dot_loc]}(1)', f'{file_destination[dot_loc:]}'
rename(file_location, file_destination)
else:
rename(file_location, file_destination)
解决方案
推荐阅读
- java - 无法将 springboot REST api 部署到 Heroku
- neo4j - 在 Neo4J 中查找图中节点之间的长度(最远)
- arrays - 谷歌表格 IF 函数返回值
- c++ - 如何在 omnet++ 中将 simtime 转换为双值?
- java - Spring Boot Junit 使用构造函数注入测试注入 dao 接口
- javascript - Elasticsearch:跨多个索引返回唯一记录
- java - Java Regex 匹配 Pattern 或 Pattern 中的任何子字符串
- primefaces - 无法链接 org/primefaces/application/resource/DynamicResourcesPhaseListener:javax/faces/event/PhaseListener
- php - Laminas Framework 中的函数 setInputFilter() 是什么以及如何使用它?
- ios - 带有 ObservedObject 的视图,没有任何东西可以让我编辑它