+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Request for script to copy files in Coding and Web Development; I would like to have a script that I can run in a class folder (that folder has all the ...
  1. #1
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,828
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39

    Request for script to copy files

    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.

  2. #2

    Domino's Avatar
    Join Date
    Oct 2006
    Location
    Bromley
    Posts
    4,020
    Thank Post
    212
    Thanked 1,164 Times in 758 Posts
    Blog Entries
    4
    Rep Power
    481

  3. #3
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,828
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    But how would I get it to go through each child's folder in the class folder? needs some kind of loop?

  4. #4
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,828
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    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

  5. #5
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,828
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    Sorted now, just needed to change the format of the date I was comparing it to!

  6. #6

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    64
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 22
    Last Post: 15th June 2010, 08:16 AM
  2. Replies: 5
    Last Post: 17th September 2009, 10:52 PM
  3. Replies: 3
    Last Post: 25th September 2006, 12:27 PM
  4. Replies: 19
    Last Post: 20th June 2006, 03:53 PM
  5. script to copy files to machines
    By browolf in forum Scripts
    Replies: 1
    Last Post: 28th November 2005, 10:28 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •