I have a directory having so many number of files. Now I want to move the files which are older than one month (lets say) from this directory to another directory (say BKP dir).
Simply, if file is olderthan one month move it from source1 dir to BKP1 dir.
My file names doesn't have any time stamps in their names, so we have to move based on the file creation date.
Thanks for your reply, adding one constraint to this. Please don't mind.
I have one text file (say dont_move.txt), where some file names are written into that in a line by line manner. So now I need to perform the above code if the name is not in the file (dont_move.txt).
If a file is olderthan 30 days and that name is entered into dont_move.txt, then we need to skip that.
As your file names contain spaces, you will need to fiddle around with the escaped double quotes around the final {}. Remove echo as you see command fit your needs.
will all produce the same results (but the last one will run faster since mv will be executed less often to move the files). This works for any files on the system even if the filenames contain spaces, tabs, and newlines.
it won't work if any filenames contain a newline. On some systems you can get around this using -print0 in find instead of -print and then use a special option in the program reading filenames from the piped output of find, but these options are not in the standards (so they are not portable).