Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving files by date 1

Status
Not open for further replies.

fathead

IS-IT--Management
Apr 13, 2002
154
I need to move several files that to another location based on date. I have a doctors office taht has 6 transcriptionists working full time. They save all their WP docs to wpdocs dir and have run out of inodes (but still have about 500 mb left on drive). I want to move all files that are more than 365 days old to another drive. How can I do this????
 
man find

one option is select by age of files, and then look at exec option to do the move.

 
Since I happen do this on a regular basis, here is the command:

/bin/find /sourcedir -mtime +365 -exec /bin/mv {} /destinationdir \;
 
Hi:

There's certainly nothing wrong with the following command, and It's not the problem it once was, but I've seen this fail:

/bin/find /sourcedir -mtime +365 -exec /bin/mv {} /destinationdir \;

by overflowing the command buffer and overwhelming the mv command if you have a very large number of files. This command uses xargs:

find ./ -type f -mtime +365 -print | xargs -l56 -i mv -f {} ./newdir

and only sends 56 files at a time to mv.

Regards,

Ed

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top