Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 moving oldest 1000 files from a folder 10000 10

Author  Topic 

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 13:07:49
How to move the oldest 1000 files from a folder that contains 10000 files.
The file names are tickcounts with extension xml.

Thank you

sarah

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-29 : 14:17:47
does file name contain timestamp information?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 16:33:19
No the name is produced by gettickcount
Thank

sarah
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-29 : 16:48:00
so what will be a typical filename? is there anything in it from which you can derive the sequence of arrival?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 16:56:05
I will send an example within an hour it is a long number that can never be repeated
Thanks

sarah
Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 17:29:14
It is increasing but it is a long number
Thanks

sarah
Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 18:07:38
Can I sort descending by the time they reach our folder in nano second

sarah
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-29 : 18:23:52
but do you've the time stored somewhere?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 22:11:51
Hi the sample of files
file name:1327338235762.xml has in its content <datetime>2012-01-23T09:03:45</datetime>
file name:1327338263700.xml has in its content<datetime>2012-01-23T09:04:14</datetime>
file name:1327338353934.xml has in its content<datetime>2012-01-23T09:05:37</datetime>
file name:1327338354700.xml has in its content <datetime>2012-01-23T09:05:37</datetime>
file name:1327338504372.xml has in its content<datetime>2012-01-23T09:07:59</datetime>

The other issue is that files are continuously coming so when I try to read file it says it is used by another user
if a file name is like the ones i mentioned above shall I sort by file name ascending so the new ones will be at the end so I will not have the error message that it is used by another user

Thank you so much for your help

sarah
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-29 : 22:18:21
what you can do is set up a for each loop in ssis to read through files. inside loop, as a first step retrive filename and populate a table with it. During each iteration take only those files which are not present in table. this will avoid same file been taken again. for sorting use number in filename and then generate sequence number based on that. then put a loop to delete all files which come in the beginning upto limit you want (1000 or something)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-01-29 : 22:32:14
Thank you

sarah
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-29 : 22:51:38
let us know how you get on

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -