Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Move files based on datetime in filename

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
StephenD Posted - 10 September 2011 : 23:17:17
I'm trying to find a script in a batchfile that will move log files from one folder to another.

My files are in the named format 20110801.txt, 20110802.txt etc

I want to only move files older than 12 months and I can't use datecreated as all the files were moved to a new server and have the same datecreated/modified stamp from the migration process.

I have to use the date stamp in the file name as my trigger.

Any ideas?
3   L A T E S T    R E P L I E S    (Newest First)
HuwR Posted - 12 September 2011 : 08:24:32
you shouldn't need to convert them to datetime, if they are of the form yyyymmdd then you can just compare them as strings since

"20100101" < "20110101" is true for a string or a date
Shaggy Posted - 12 September 2011 : 07:56:35
The way I'd do it in ASP would be to use the FSO to loop through all the files, convert each file name to date format, use datediff to compare that date to today's date and move the file if datediff is more than 12 months. Don't know much about batch files but the process, at least, should be the same.

pierretopping Posted - 11 September 2011 : 16:02:23
Hi,

I use robocopy(google it, its free) for that exact job. You can place a min date parameter to set what age files you want. PM me if you want a copy of the batch file.

Or maybe just use wildcards in the file name for now?

Pierre

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000 Version 3.4.07