Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Copying Files Based On Modified Date

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62056
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Copying Files Based On Modified Date
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Copying Files Based On Modified Date - 7/1/2008 1:24:02 AM   
  Slenk9980


Posts: 27
Score: 0
Joined: 7/1/2008
Status: offline
Below is the current code I am running. I find myself having more files than I need in the copy location. How can I modify my code to only copy say files modified in 2008?

Thanks!


      
 
 
Post #: 1
 
 RE: Copying Files Based On Modified Date - 7/1/2008 1:27:47 AM   
  dm_4ever


Posts: 2414
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
This is a frequently asked question....have you searched?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Slenk9980)
 
 
Post #: 2
 
 RE: Copying Files Based On Modified Date - 7/1/2008 1:33:15 AM   
  Slenk9980


Posts: 27
Score: 0
Joined: 7/1/2008
Status: offline
I did do a search and found 1 thread with 1 response but not answered. I apologize if I've asked a previously answered question.

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Copying Files Based On Modified Date - 7/2/2008 2:46:14 AM   
  Slenk9980


Posts: 27
Score: 0
Joined: 7/1/2008
Status: offline
Can some one point my in the right direction? I can't seem to find how to copy files based on modified date.

Sorry.

(in reply to Slenk9980)
 
 
Post #: 4
 
 RE: Copying Files Based On Modified Date - 7/2/2008 3:38:00 AM   
  Slenk9980


Posts: 27
Score: 0
Joined: 7/1/2008
Status: offline
Ok here's what I found. This oviously copies all files that are older than 1 month.

How can I look at certain file types? Like I want to copy only *.txt files older than 1 month.

I aplogize for not putting the code in brackets. Copied from an email and it was putting in all kind of funky stuff.





Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Temp\")
 
Set colFiles = objFolder.Files
 
dtmMonthAgo = DateAdd("m", -1, Now)
 
For Each objFile in colFiles
    If objFile.DateLastModified < dtmMonthAgo Then
        objFSO.CopyFile objFile.Path, "C:\Temp\Old\"
    End If
Next




 

(in reply to Slenk9980)
 
 
Post #: 5
 
 RE: Copying Files Based On Modified Date - 7/2/2008 4:10:40 AM   
  Rischip


Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline

      

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Slenk9980)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Copying Files Based On Modified Date Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts