在SVN中搜索具有特定文件扩展名的文件并复制到另一个文件夹?

时间:2021-12-06 03:41:06

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. 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脚本搜索SVN中的目录,找到以特定扩展名结尾的文件(例如。* .exe),并将这些文件复制到我在C盘中创建的目录中。我怎样才能做到这一点?我是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)?

1 个解决方案

#1


1  

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. There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python.

我认为使用svn命令行实用程序检查(或更好地导出)源代码树是最简单的:您可以使用os.system来调用它。还有直接的Python-to-svn API绑定,但如果你是Python新手,我建议不要使用它们。

You can then traverse the checkout folder, e.g. using os.walk; the copying itself can be done with shutil.copy.

然后,您可以遍历结帐文件夹,例如使用os.walk;复制本身可以使用shutil.copy完成。

#1


1  

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. There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python.

我认为使用svn命令行实用程序检查(或更好地导出)源代码树是最简单的:您可以使用os.system来调用它。还有直接的Python-to-svn API绑定,但如果你是Python新手,我建议不要使用它们。

You can then traverse the checkout folder, e.g. using os.walk; the copying itself can be done with shutil.copy.

然后,您可以遍历结帐文件夹,例如使用os.walk;复制本身可以使用shutil.copy完成。