TechSupp Posted July 14, 2010 Posted July 14, 2010 I would like to have a script that I can run in a class folder (that folder has all the childrens folders which contain their work) that will create a new folder in each child's folder called '2009-10' then move all their work (excluding folders) into the new folder, leaving it ready for the new years work. Do it manually at the moment. It must be possible but haven't a clue how to do it.
Domino Posted July 14, 2010 Posted July 14, 2010 Have a butchers at robocopy - Robocopy Syntax, Command Line Switches and Examples » My Digital Life
TechSupp Posted July 14, 2010 Author Posted July 14, 2010 But how would I get it to go through each child's folder in the class folder? needs some kind of loop?
TechSupp Posted July 15, 2010 Author Posted July 15, 2010 Had a look aroung and got a script to work but just going the extra mile now and want to sort all the files out. I need to compare file creation dates and then depending on their date move them to a certain folder. Got the vbs code below but it just seems to copy everyfile into the 2009-10 folder even if its date stamp is 2008? Anybody spot my mistake? dim oFSO, oFolder, srcfolder, tgtfolder, oFile, creationdate srcfolder="C:\Documents and Settings\user\My Documents\pupils\Pupil 1" set oFSO = CreateObject("Scripting.FileSystemObject") set oFolder = oFSO.GetFolder(srcfolder) for each oFile in oFolder.files creationdate = datevalue(oFile.DateCreated) If (creationdate >= "01/09/2009") And (creationdate <= "31/08/2010") then tgtfolder="C:\Documents and Settings\user\My Documents\pupils\Pupil 1\2009-10" oFSO.MoveFile srcfolder & "\" & oFile.name , tgtfolder & "\" elseif (creationdate >= "01/09/2008") And (creationdate <= "31/08/2009") then tgtfolder="C:\Documents and Settings\user\My Documents\pupils\Pupil 1\2008-09" oFSO.MoveFile srcfolder & "\" & oFile.name , tgtfolder & "\" end if next set oFolder = nothing : set oFSO = nothing
TechSupp Posted July 15, 2010 Author Posted July 15, 2010 Sorted now, just needed to change the format of the date I was comparing it to!
OutToLunch Posted July 15, 2010 Posted July 15, 2010 I was just about to add a batch file version then scrolled to the end of the thread - any chance of posting your finished/working script? Looks like a very handy tool for tidying up at the end of term
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now