Script for moving files from one folder to other

Hi

I need to move last 1 year old files from one folder to another location on same server.How to write a shell script for the same?

thanx
Lalit

Hi,

Try this

find <source dir name> -mtime +365 | mv *.* <destination directory>

Thnks and Regards,
Subin

Thanx for quick response

but how to run this script bcoz i m new in unix evironment.

lalit

#####################
#!/bin/sh

find <source dir name> -mtime +365 | mv *.* <destination directory>
#########################

save this file as move.sh and try a run... Hope you got

Thanks,
Parkkavan

#!/bin/sh

find <source dir name> -mtime +365 | mv *.* <destination directory>

thanx for reply

where I put this file in machine?

Hi

 I have to added in this script to tell to "Do you want to move the files" with Yes or No option, every time when I run this query.

thanx in advance

Lalit

Hi Lalit,

Please go through unix tutorial and try on your own. This is not a much big deal. Simple if else statement can do it.

  1. Are you going to run as a cron job?
  2. Expain whats your exact need? Summarize it fully

Thanks,
Parkkavan

Thanx for reply

I need a script for moving one year old files from one folder to another folder on same server with autehntication---.

Thanx
Lalit