Archive files by date - year

E

efromeroc

Guest
Any suggestion about how can I move files by year to a specific folder. the chalenge is that the original folder has millions of files, so I cannot list the files.
 


R

Rob

Guest
Sure - this is probably a round-about way, but it should work.. touch two files for each year.. we'll use 2011.. compare files in the dir to those files.. move the ones that match..

[xcode=shell]
mkdir /path/to/2011
touch --date "2011-01-01" /tmp/start
touch --date "2012-01-01" /tmp/end
for f in `find /path/to/millionfiles/ -type f -newer /tmp/start -not -newer /tmp/end`; do mv $f /path/to/2011/;done
[/xcode]

It may end up taking up all of the server resources.. so be ready to kill it :)
 
D

DarthVader3257

Guest
I think that some coding will enable you to archive certain files by date and year. On Windows, it's obviously a lot easier due to the fact that you can simply select the way you would like for the files to be organized. Hope the issue had been solved, though.
 


Members online


Latest posts

Top