473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

vbscript - move files older than 180days based on modified date keeping the original

Hello All
I have the following vbscript and i need help to modified in order to meet my needs since i dont know how to do it.
the script is:

-----------------------------------BEGIN OF SCRIPT---------------------------------------------------

Dim objFSO, ofolder, objStream

Set objShell = CreateObject("WScript.Shell")

Set objFSO = CreateObject("scripting.filesystemobject")

Set objNet = CreateObject("WScript.NetWork")

Set FSO = CreateObject("Scripting.FileSystemObject")

set outfile = fso.createtextfile("Move-Result.txt",true)

SPath = "c:\temp\"

ShowSubfolders FSO.GetFolder(spath)

Sub ShowSubFolders(Folder)

For Each Subfolder in Folder.SubFolders

CheckFolder(subfolder)

ShowSubFolders Subfolder

Next

End Sub

'CheckFolder(objFSO.getFolder(SPath))

Sub CheckFolder(objCurrentFolder)

Dim strTempL, strTempR, strSearchL, strSearchR, objNewFolder, objFile

Const OverwriteExisting = TRUE

currDate = Date

dtmDate = Date - 180

strTargetDate = ConvDate(dtmDate)

For Each objFile In objCurrentFolder.Files

FileName = objFile

'WScript.Echo FileName

strDate = ConvDate(objFile.DateCreated)

'strDate = ConvDate(objFile.DateLastModified)

If strDate < strTargetDate Then

objFSO.MoveFile FileName, "e:\test\"

outfile.writeline filename

End If

Next

End Sub

Function ConvDate (sDate) 'Converts MM/DD/YYYY HH:MM:SS to string YYYYMMDD

strModifyDay = day(sDate)

If len(strModifyDay) < 2 Then

strModifyDay = "0" & strModifyDay

End If

strModifyMonth = Month(sDate)

If len(strModifyMonth) < 2 Then

strModifyMonth = "0" & strModifyMonth

End If

strModifyYear = Year(sDate)

ConvDate = strModifyYear & strModifyMonth & strModifyDay

End Function

---------------------------------------------END OF SCRIPT-------------------------------------------



the thing is that i want help to the following:



1) to check the files in the folders and subfolders of the location c:\temp and based on the MODIFIED DATE to move them to the location e:\test

2) To keep the same exact directory structure in the new location e:\test

3) to have the ability to place somewere *.* to select all files from c:\temp or to put *.xls and to find and move only the .xls files that havents been used for 180 days with the same directory structure to e:\test.

Since i want to deploy this script with GPO i would like to replace the e:\test to an external HDD with the variable of the username. I intent to do this per user.

Any help will be appreciated.

thx
Mar 16 '11 #1
0 1664

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Dennis Marks | last post by:
There seems to be a major program with the automatic display of the last modified date. Using the javascript "document.lastModified" sometimes returns the correct date and sometimes 1 Jan 1970...
6
by: Mark | last post by:
Using VS.NET 2003 I have one asp.net application where the modified date never changes. I have other solutions (asp.net/desktop) where the modified date does change. This has been going on for...
0
by: richardkreidl | last post by:
Let's say I have the following folder: C:\Archive\Data\Logs\ and within this folder are many files in this format: Cycle Run of Tuesday, February 01, 2005.html Cycle Run of Wednesday, February...
4
by: IdleBrain | last post by:
Hello All, Is it possible to obtain the last Modified date for the source code from within the application? If yes, please let me know how it is done.
1
by: Marcel Brekelmans | last post by:
Hello, I know about the FileInfo.LastWriteTime() function. However, this is not always returning the modified date of the executable that I want: when you copy the executable to another...
1
by: GeoDW | last post by:
Hell All, I have looked around and not found the solution I am looking for within the old threads. Here is my problem: I have a directory full of .img and .rrd files that have long filenames...
2
by: moonbug | last post by:
How can I move files based on date specifically for the case below: 1. crontab runs every hour 2. any file in directory 1 dated less than the current hour is moved to directory 2. eg file1...
3
by: jaeden99 | last post by:
I was wandering if nyone has a script to move files older than x days old? i've seen several to delete, but I don't want to delete. I would like to create a backup of the files first verify with...
11
by: strychtur | last post by:
Hi all, I have a vbscript that renames msg files to Sender - Subject. What I am looking to do is change the modified date of the msg file to be the received date of the email. The thing is I could...
2
by: xavix | last post by:
Hello, How can I move files based on age in the following scenario: $SOURCE contains some subfolders with some files inside them. Each subfolder contain files of the same date, but the last...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.