September 10, 2008 at 4:33 pm
I need to delete files from folder and sub folders. And also i shouldn't delete present hour data . I mean if i run the packag at 1.00 PM then it should not delete the files which generated at 1.00PM.
I thought of writing batch files but may be SSIS script is better one. Please share the code. Thanks.
September 10, 2008 at 4:47 pm
What we we do is, archive the files with datestamp to a different folder a first step and then copy the file to desired folder and ovewrite it. For both Filesystemtask in SSIS is very useful.
VG
September 10, 2008 at 5:06 pm
I shared this idea with my team but b/c of the Server space , we can't do like this. So can you share your code to delete files from folder and subfolder and also need to keep current hour data. It is very urgent for me since we are running out of space in our server.
or Batch file also fine.
Thanks a lot.
September 10, 2008 at 5:17 pm
File system task can do this. Select either, delete file, delete directory, delete directory files according to your needs. I am not sure about the keeping only current files though...
Are you sure you want to delete all files in folders and subfolders ?
VG
September 10, 2008 at 5:31 pm
No, I need to keep current hour files and delete all other files. It means if i run the package at 1.00PM then the package shouldn't delete the files which generated at 1.00PM. Files are generating every 2 mins.
I have batch file to delete all the files from folder and subfolder. But i don't know how to keep current hour files. Even "forfiles" command also doesn't have keeping current hour files option. only have day.
So , i am looking those kind of SSIS package or Batch file.
Thanks for your immediate response.
October 8, 2008 at 9:17 am
u got this task done?? even I m waiting for the same task... please help me out if someone knows this....
October 8, 2008 at 1:35 pm
We can do with Batch file with Delen command. I didn't try but someone sugges me. You can download Delen program from this link.
Let me know .
October 8, 2008 at 1:39 pm
I think we r not supposed to download these in production servers...But Thanks for the information...
October 9, 2008 at 8:35 am
We use the following to remove files x number of days old. I think it might work with hours, too.
For days:
forfiles /p C:\My Folder\ /s /m FilenamePrefix*.txt /d -7 /c "cmd /c del @path"
Try this for hours:
forfiles /p C:\My Folder\ /s /m FilenamePrefix*.txt /h -2 /c "cmd /c del @path"
Give it a try. I hope it works for you.
October 9, 2008 at 8:57 am
Hey RML51..........could you please explain in detail...where I should use the command given by you...I have for each loop container and file system task...I created a user variable...I don't know what value should be given to the variable...
Thank you
October 9, 2008 at 9:11 am
I just checked and unfortunately it doesn't look like it'll work with hours, only days.
http://technet.microsoft.com/en-us/library/cc753551.aspx
Sorry for the false hope.
October 9, 2008 at 9:32 am
Thanks for the reply....but where should we use this command? in the ssis package?? or cmd?? I m very novice in this...please don't mind...I just need to delete 15 days old files...
October 9, 2008 at 9:38 am
We run it in a .bat command file, and then execute that using scheduled tasks.
October 9, 2008 at 9:40 am
ok kool...now I got it...Thanks a lot...
October 9, 2008 at 9:42 am
Can you pls tell me any commans work with hours? I need to keep current 1 hr file and need to delete all other fils. Thanks.
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply