MSDOS 命令将目录结构中匹配模式的文件复制到本地目录
我有一项定期运行并将文件存档到如下所示的文件夹结构中的作业:
ArchiveFolder
TimestampFolder
JobnameFolder
job<timestamp>.xml
对于给定的作业,我想将存档文件夹中的所有 xml 文件收集到一个平面目录中(没有子目录,只有所有文件)无需深入研究每一项,检查正确的作业,然后复制文件。
似乎应该有一种相当简单的方法来做到这一点。有什么建议吗?
编辑:我想我在这里不清楚。 TimeStampFolder 的名称类似于 2011-07-24
,JobnameFolder 的名称类似于 FooFeed
或 BarFeed
,作业的名称类似于 FooFeed
或 BarFeed
。文件的名称类似于 job2011-07-24.xml
。 TimeStampFolder 有成百上千个,每个 TimeStampFolder 中可能有一个或多个作业文件夹。给定一个特定的作业名称,我想收集与该作业类型匹配的所有目录中的所有文件,并将它们转储到本地文件夹中,没有子目录。
I have a job that periodically runs and archives files into a folder structure that looks like this:
ArchiveFolder
TimestampFolder
JobnameFolder
job<timestamp>.xml
For a given job, I'd like to collect all xml files in the archive folder into a flat directory (no subdirectories, just all the files) without having to drill down into each one, examine for the proper job, then copy the file.
It seems there should be a fairly straigtforward way of doing this. Any suggestions?
EDIT: I guess I wasn't clear here. The TimeStampFolder will have a name of something like 2011-07-24
, the JobnameFolder will have a name like FooFeed
or BarFeed
, and the job file will have a name like job2011-07-24.xml
. There are hundreds to thousands of TimeStampFolders, and each one may have one or more job folders in it. Given a specific job name, I want to collect all the files in all the directories that match that job type, and dump them into the local folder, with no subdirectories.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
EDIT1:
它基本上找到了 ArchiveFolder 中包含 JobName 的每个子目录,然后深入到它找到的每个子目录中,以从中复制文件。
EDIT2:
添加了 NET USE 来访问网络共享以对文件执行任务。如果您的本地计算机已将 UNC 分配给驱动器号,则可以删除 NET USE 命令行并将 Z: 更改为分配的驱动器号。
EDIT1:
It basically locates each subdirectory of ArchiveFolder that includes the JobName in it, then digs into each one that it finds to copy the files out of them.
EDIT2:
Added NET USE to access your network share to perform tasks on the files. If your local machine already has the UNC assigned to a driveletter, you can remove the NET USE command line and change Z: to the assigned driveletter.