简体   繁体   English

复制/移动上次修改日期的所有文件在给定月份内

[英]Copy/move all files which last modified date are in a given month

I have a question about terminal command. 我有关于终端命令的问题。 At work, we receive in a folder many files everyday. 在工作中,我们每天在文件夹中收到许多文件。 Today we decide to organize this full amount of files collecting them in folders using year and month as a rule. 今天我们决定使用年份和月份来组织这些全部文件收集在文件夹中。

Question, how can i move all the files which last modified date are in the range of the month of April of 2013, for example. 问题,例如,如何移动上次修改日期的所有文件都在2013年4月的范围内。

You can easily select files whose modification times are in a time range with the find command. 您可以使用find命令轻松选择修改时间在时间​​范围内的文件。 Here's an example with gnu find, which makes this fairly simple: 这是gnu find的一个例子,这使得这很简单:

find . -newermt 'Apr 1, 2013 00:00' -not -newermt 'May 1, 2013 00:00' \
       -exec mv -t /path/to/April_2013/directory '{}' '+'

man find for all the gory details. man find所有血淋淋的细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM