I have 3 folders f1
, f2
and f3
.
How can I move every file from f1
and f2
that the dates are from the 22 jun 2016 till the 21 of september 2018 to the folder f3
, in one command maybe using mv
?
Since you've tagged with ubuntu I am going to assume GNU tools
find f1 f2 -maxdepth 1 -type f -newermt 2016-06-22 ! -newermt 2018-09-21 -exec echo mv -t f3 {} +
I may have the dates wrong by ±1 day on each side - please check this and adjust accordingly. When you are happy you can see that the mv
command has received the correct files, remove the echo
prefix.
With zsh
:
autoload age
mv (f1|f2)/*(.e[age 2016-06-22 2018-09-21]) f3/
(note that it matches on files (regular files only with the .
glob qualifier) last modified between the start of those 2 days. If you also want to move the files modified any time on 2018-09-21, you'll need to change the second date to 2018-09-22).