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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving Multiple files based on date?? 1

Status
Not open for further replies.

tricue

IS-IT--Management
Oct 4, 2004
4
US
I am looking for a way to move multiple files (reports) from one directory to another based upon the files date.

There are no common names to these files to use the mv command with a name wildcard.

Is there a way to select all files with a last modified date of prior to 12/31/2002 and move them to another directory?? (around 20000 files).

Thanks!!!
 
After reviewing the recommended posts I have come to the following command but still unsure how I get the move command to work properly in the find statement.

Here is what I have been attempting.

find . \( -type d ! -name . -prune \) -o \( -type f -mtime +637 -exec mv {} /desiredpath/; \)

What do I need to change??

Thanks Chacalinc - for your direction so far!!
 
find . \( -type d ! -name . -prune \) -o \( -type f -mtime +7 -ok mv {} /desiredpath/. \; \)

note that:

-exec will execute the "mv" command.
-ok will prompt (ask you) wheter run the "mv" command.

Cheers.
 
you could try first:

find . \( -type d ! -name . -prune \) -o \( -type f -mtime +7 -exec ll {} \; \)

this will *list* the files...

Cheers.
 
BTW i use the -mtime +7 just for local test, you must use the +637..

 
Thanks Chacalinc,

The following command worked like a charm:

find . \( -type d ! -name . -prune \) -o \( -type f -mtime +637 -exec mv {} /desiredpath/ \; \)

had to replace the ";" with " \;"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top