April 12, 2010 at 7:54 am
We receive files from outside vendors that need to be deleted on a regular basis.
We would like to remove files that are older then say 10 days for now and after process is in full swing shring that down to 3 or so days.
Any t_sql , ssis or vb.net suggestion would be great
April 12, 2010 at 10:29 am
How about a Windows command prompt / batch file / scheduler solution?
In Windows 2003/Vista and later, there is the FORFILES command that you can use to cycle through a group of files, selecting them based on a number of different criteria (including age) and perform an action on them (such as 'delete'). Schedule it with the Windows scheduler and you're set.
Type FORFILES /? at a command prompt for more details and examples.
Rob Schripsema
Propack, Inc.
April 12, 2010 at 10:33 am
sorry Forfiles is not a command on my machine or the ftp server. But thanks for the idea
April 12, 2010 at 12:41 pm
Can you tell us what the environment is so that we don't offer any more suggestions that are not on your workstation or FTP server?
I like the idea of a batch file and windows task scheduler (this could also be a cron job if you have a non windows FTP server).
Also this could be done with vbscript and the filesystem object or Powershell or even a maintenance plan. It all depends on your environment, what you have available to you etc... Help us to help you.
-Luke.
April 12, 2010 at 1:03 pm
I was just informed the machine and environment of my ftp server is
Mac OS 9.1
April 12, 2010 at 1:20 pm
And you are looking to be able to do this maintenance from your ftp server or from a client connecting to the ftp server? If you are looking to do the maintenance directly on the ftp server, I'm sure that Mac OS9 has some type of scheduling component, although I do not know if they have a command line. Either way I'd suggest digging into your Mac documentation.
If however you are looking to do that via an ftp task in the windows world you will need to see if your remote ftp server can programatically tell you which files were created on which date and then you can delete them based on that. Are the files names like 2010-apr-12.txt or some such that you'd be able to tell a file was created today?
Any more information you can provide about your situation would be extremely helpful otherwise we are just taking shots in the dark here...
-Luke.
April 12, 2010 at 1:37 pm
I have not been able to code a request for file metadata (date created)
I am able to delete a file there providing I have the name of the file.
I thought I would just
transfer the file to a junk folder on my machine
get the date created
build a list of old files
delete all the files in junk and the old ones on ftp.
But when transfering a new create date is issued.
April 12, 2010 at 2:22 pm
OK so now we're getting somewhere...
I still might think about doing this in a windows command file using unattended FTP. You could use vb script, perl or a variety of other languages whatever you happen to be adept at. Here's roughly how I might go about doing it. I'd use the unattended ftp or something like it to get the file listing (the results of ls or dir command for your ftp server and output it to a table breaking the text into the various columns you need. (or store it as an array or text file or what have you, but since this is in the TSQL forum...)
then I'd query that table for the file names to be deleted and using an For Each loop iterate through them sending the ftp the appropriate delete command based on the filename.
Again this can be done a number of different ways it all depends on where you skill set lies.
-Luke.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply