Python - 如果目录包含以...开头的文件...移动文件
我需要在 Python 中创建一个脚本,该脚本将查找一个目录(仅包含一个文件),如果该文件不是当天的文件,则将其移动。作为参考,该文件有一个与当天相关的后缀(myfile_030811.xls
)
有人对此有任何想法吗?
I need to create a script in Python which will look to a directory (which contains only one file) and move it if the file is not for the current day. For reference the file has a suffix which relates to the current day (myfile_030811.xls
)
Does anyone have any ideas for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

试试这个?这假设当前目录下存在一个名为“archived”的目录。您可能想调整它以满足您的需求。另外,这还假设您目录下的所有文件都具有结构 _ddmmyy 的名称。格式。否则它不会工作
try this? This assumes that a directory called 'archived' is present under the current directory. you might want to tweak it to suit your needs. Also this assumes that all files under your directory have a name of the structure _ddmmyy. format. It won't work otherwise