Jump to content

Recommended Posts

Posted
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.
Posted

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

Posted
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 :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...