[英]batch file copy multiple .txt files with date restrictions from multiple directories to one directory
I am trying to copy all .txt files that I have scattered throughout several subdirectories of one main directory into another directory using a batch file. 我正在尝试使用批处理文件将分散在一个主目录的几个子目录中的所有.txt文件复制到另一个目录中。 I have research this site and found lots of answers at this link: batch file Copy files with certain extensions from multiple directories into one directory .
我研究了该站点,并在此链接找到了很多答案: 批处理文件将具有某些扩展名的文件从多个目录复制到一个目录中 。 Like the code below from Jay:
像下面来自Jay的代码:
set dSource=C:\Main directory\sub directory
set dTarget=D:\Documents
set fType=*.doc
for /f "delims=" %%f in ('dir /a-d /b /s "%dSource%\%fType%"') do (
copy /V "%%f" "%dTarget%\" 2>nul
) )
My question is how to modify this code or other codes on this link to batch copy the files with time stamps, like I only want to copy .txt files created from Jan 1, 2012 to Nov 1, 2012. 我的问题是如何修改此代码或此链接上的其他代码,以批量复制带有时间戳的文件,就像我只想复制从2012年1月1日到2012年11月1日创建的.txt文件。
My suggestion for finding and moving *.txt files in a directory tree of a drive, or the entire drive, or even multiple drives with last modification date in a definite time period is: 我建议在一个驱动器或整个驱动器,甚至多个驱动器的目录树中查找并移动* .txt文件,并在确定的时间段内最后修改日期是:
That's it. 而已。
Nobody needs to code a batch job for this task if this find + move files job should not be done periodically using a scheduling task. 如果不应使用计划任务定期执行此查找+移动文件作业,则无需为该任务编写批处理作业。
The exact steps for doing such an advanced find for files in a definite time period with Windows Explorer depends on version of Windows. 使用Windows资源管理器在特定时间段内对文件进行这种高级查找的确切步骤取决于Windows的版本。 See for example the computer tips
参见例如计算机提示
And of course there are many freeware and shareware tools which support also finding files according to various search criterias like last modification date within a specified time period and move them. 当然,还有许多免费软件和共享软件工具,它们也支持根据各种搜索条件(例如,指定时间段内的最后修改日期)查找文件并将其移动。
Well, that does not really answer the question as it does not contain the batch code for doing the job. 好吧,因为它不包含执行该工作的批处理代码,因此并不能真正回答该问题。 So I answer this question with another question:
所以我用另一个问题回答了这个问题:
Why thinking about coding a batch file for such a task hard to adapt for varying dates if dozens of GUI applications including Windows Explorer exist doing the same by simple user input with no need on coding skills and therefore very easy to use, and the find + move must be done only once or from time to time with changed criterias? 如果存在包括Windows资源管理器在内的数十个GUI应用程序,只需简单的用户输入即可完成,而无需编码技能,因此为什么要考虑为难以适应不同日期的批处理文件编码,因此非常易于使用,必须仅在更改标准后一次或不时进行移动?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.