Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with copying and moving

Status
Not open for further replies.

jamesholyoak

Programmer
Mar 31, 2003
1
US
I am having a problem with this script. I want to go into a folder, check if any of the documents are more than a week old and if they are, copy them to a another folder.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='c:\test'}
For Each objfile In FileList

window.onload=fnInit;
function fnInit(){

var oCreated=new Date(document.fileCreatedDate);


var oToday=new Date();


var iMilliSeconds=86400000;
var iDaysBetween=(oToday.getTime() - oCreated.getTime()) / iMilliSeconds;

alert("Created: " + oCreated + "\nDays since created: " +
parseInt(iDaysBetween));}

If iDaysBetween > 6 Then

objfile.Copy "E:\group_1\app1"

Next
End
 
jamesholyoak,

Suggest you look at the following pages. You should be able to discern the code that would address the two parts of what you want your code to perform. Atleast what I gathered from your request.

Delete Files Based On Creation Date With Event Logging

Delete Files Based On Last Modified Date

Delete Files That Have Not Been Modified In X Days

Incremental Backup (copy) With Logging

Hope this helps.
DougCranston
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top