python - 使用python将文件从一个位置移动到另一个位置
问题描述
如何使用 python 将文件复制到目录中。我的所有 AB.jpg 都应复制到一个文件夹,而 BC.jpg 文件应复制到另一个文件夹,方法是使用文件路径中的日期对文件进行子脚本编写)。我创建的路径是基于时间戳动态的。
我的本地目录路径格式如下:
directory : /tmp/hash/inputsrc/20201229/....../AB.jpg
/tmp/hash/inputsrc/20201228/....../BC.jpg
/tmp/hash/inputsrc/20201229/....../AB.jpg
/tmp/hash/inputsrc/20201228/....../BC.jpg
Expected output:
/newfolder/AB_20201229.jpg
/newfolder/AB_20201228.jpg
/newfolder/BC_20201229.jpg
/newfolder/BC_20201228.jpg
解决方案
推荐阅读
- python - 在 python 函数中解包 python 元组
- html - HTML & CSS - 与 IE 的格式差异
- sql - 为什么 SQL Server 不使用我的聚集索引并执行非聚集索引扫描?
- r - 从 R 中数据框中的现有列创建新的竞赛变量(使用 case_when 函数)
- html - [HTML&CSS]为什么CSS文件不适用于html?:/ :/
- case - Verilog HDL 始终和案例错误
- android - Flutter 在 MainActivity 之外调用 MethodChannel 和 EventChannel
- flutter - 我需要我的子容器占用相等的空间而不指定容器宽度
- python - 执行分组后删除异常值
- python - 读取带盒装问号的 csv