[英]Search directory in SVN for files with specific file extension and copy to another folder?
I would like my python script to search through a directory in SVN, locate the files ending with a particular extension (eg. *.exe), and copy these files to a directory that has been created in my C drive. 我希望我的python脚本搜索SVN中的目录,找到以特定扩展名结尾的文件(例如* .exe),然后将这些文件复制到在C驱动器中创建的目录中。 How can I do this?
我怎样才能做到这一点? I'm new to Python so a detailed response and/or point in the right direction would be very much appreciated.
我是Python的新手,所以非常感谢您提供详细的响应和/或指出正确的方向。
Follow-up: When using os.walk what parameter would I pass in to ensure that I'm copying files with a specific extension (eg. *.exe)? 后续措施:使用os.walk时,我将传入什么参数以确保我正在复制具有特定扩展名的文件(例如* .exe)?
I think it is easiest to check out (or, better, export) the source tree using the svn command line utility: you can use os.system to invoke it. 我认为使用svn命令行实用工具检出(或更好地导出)源树是最容易的:您可以使用os.system来调用它。 There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python.
也有直接的Python到svn API绑定,但是如果您不熟悉Python,我建议不要使用它们。
You can then traverse the checkout folder, eg using os.walk; 然后,您可以遍历checkout文件夹,例如使用os.walk;。 the copying itself can be done with shutil.copy.
复制本身可以使用shutil.copy完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.