Discussion Locked

I need a Script

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I need a simple script that will move files from one location to another. Except I only want to move the files that haven't been modified in 14 days or more.

10 replies

by gary_w

Put this code into a file named moveme and make it executable. Usage: moveme fromdir todir

find $1 -mtime +14 -exec mv {} $2 \;

Gary

by k_hall

I am just trying to create a routine to move files off of our FTP server than are older than 2 weeks old. Instead of deleteing I just want to move them to my PC. I would like the routine to run once a week from my Windows XP Pro machine.

by toivo talikka

You can do a lot with the available command level scripts in Windows XP. The following is quite crude and it may not be exactly what you want but if you can schedule the maintenance jobs to run at a time when your FTP server does not have much activity, it might suffice. Otherwise, you could look at the scripting support on the server itself, or a small VB or VBA program on XP.

The script uses two directories in your PC, D:\ftpbak (auxiliary directory, contains files modified recently) and D:\ftpfiles (contains all the files from the FTP directory, including the recent ones).

The script assumes that you have a mapped drive K: pointing to your FTP server directory. Create the following script and call it ftpcopy.cmd:

D:
CD \
RMDIR ftpbak /s /q
MKDIR ftpbak
CD \ftpbak
XCOPY K:\*.* /d:8-17-2005 /e /q /c /y
CD \ftpfiles
XCOPY K:\*.* /e /q /c /y
DEL K:\*.* /q /s
CD \ftpbak
XCOPY *.* K:\.

You can modify the date in the script manually, or replace the parameter /d:m-d-y with /d:%1 and call the script with the date as the input parameter:

ftpcopy 8-17-2005

You can also set up a scheduled task pointing to the script ftpcopy.cmd and get the job to start for example at 2AM on a particular day. Remember to go to the Properties of the scheduled task and add the date to the Run field of the job:

C:\mydirectory\ftpcopy.cmd 7-1-2005

Enjoy!

This discussion is closed to new replies.