[英]How to move a a certain percentage of all the files in a directory into another directory?
[英]How to move certain types of files to other directory with a Python script
我的代码是:
subprocess.call(["mv", "*.fasta", f"{my_model_dir}/."])
我得到的错误代码是:
mv: cannot stat '*.fasta': No such file or directory
我尝试将所有 fasta 文件移动到其他目录,但是,我收到一条错误消息。
我认为这是因为 '*' 在 Python 中用作正则表达式,所以在这种情况下它不起作用。 要将带有 Python 脚本的文件移动到其他目录,我该怎么办?
尝试subprocess.call(["mv", "\*.fasta", f"{my_model_dir}/."])
您可以使用os
或shutil
库:( 如何在 Python 中移动文件? )
对于同类型的文件,可以用os
循环浏览,然后一个一个移动。
os
参考:( https://www.geeksforgeeks.org/os-module-python-examples/ )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.