简体   繁体   English

批处理文件将具有日期限制的多个.txt文件从多个目录复制到一个目录

[英]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文件,并在确定的时间段内最后修改日期是:

  1. Start Windows Explorer . 启动Windows资源管理器
  2. Click on button Search . 点击搜索按钮。
  3. Open advanced search options for finding files and folders. 打开高级搜索选项以查找文件和文件夹。
  4. Select/enter to search for files by last modification date. 选择/输入以按上次修改日期搜索文件。
  5. Enter the two dates to specify time period or select the time period. 输入两个日期以指定时间段或选择时间段。
  6. Run the search. 运行搜索。
  7. Select all found files in search result, for example with Ctrl+A. 选择搜索结果中所有找到的文件,例如使用Ctrl + A。
  8. Press Ctrl+X to mark the found files for being cut (moved). 按Ctrl + X标记要剪切(移动)的找到的文件。
  9. Open the folder into which the files should be moved. 打开应将文件移动到的文件夹。
  10. Press Ctrl+V to paste the files (move them). 按Ctrl + V粘贴文件(移动它们)。

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.

相关问题 批处理文件 将具有特定扩展名的文件从多个目录复制到一个目录中 - batch file Copy files with certain extensions from multiple directories into one directory 如何将多个 .TXT 文件批量合并为一个新的 .TXT 文件? - How to batch merge multiple .TXT Files into one New .TXT File? 批处理:将文件从txt文件复制到一个文件夹中 - Batch: Copy files from txt file into one folder 批量复制来自不同文件夹的多个文件及其路径在txt文件中列出,并重命名任何重复项 - Batch copy multiple files from different folders with their paths listed in a txt file, and rename any duplicates 从多个目录递归移动文件但忽略一个目录? - Recursively moving files from multiple directories but ignoring one directory? 如何根据使用批处理文件修改的日期复制多个文件? - How to copy multiple files based on date modified using batch file? 批处理文件可将文件从一个目录复制到另一个目录 - Batch file to copy files from one directory to another 批处理-从文件名创建目录,并将这些文件复制到这些目录中 - batch - create directories from file names and copy these files in those directories Windows批处理文件检查目录中具有日期扩展名的多个文件 - Windows batch file check multiple files in a directory with date extension 使用其他目录中的文件替换子目录中的多个文件 - Replace multiple files in sub directories with file from a different directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM