Haux Posted August 2, 2011 Posted August 2, 2011 Hi all, I'm back with the same question as last year hopefully some software has been found that can do it! What I'm wanting to do is copy all the Year 11 & 13 student's contents to a Buffalo box. But there's a catch! I've got to leave the root folder behind and delete all of it's contents when transferring? For the past 6 year's we've done this by hand 1 at a time & as you can tell - it's a pain in the a-s-s! Can anyone save me? Cheers
Haux Posted August 2, 2011 Author Posted August 2, 2011 I looked at Robocopy last year but how would I make it keep the top folder? e.g. \\hosea\d$\users\students\Joe.Bloggs - Just copies file's & leaves an empty Joe.Blogg's folder. to \\Server2\userbackup\Year11\Joe.Bloggs
Admiral208 Posted August 2, 2011 Posted August 2, 2011 Would it be quicker to move them and then recreate the folders?
Haux Posted August 2, 2011 Author Posted August 2, 2011 I suggested this but it would mess up AD folder settings as if the kid's come back they won't have a home area.
featured_spectre Posted August 2, 2011 Posted August 2, 2011 Copy out all of the contents to the new area Use a batch script to recreate the root folders
Haux Posted August 2, 2011 Author Posted August 2, 2011 How would I go about keeping the folder settings within AD? Cheers
Admiral208 Posted August 2, 2011 Posted August 2, 2011 As long as you keep the same folder names, it shouldn't be a problem.
Haux Posted August 2, 2011 Author Posted August 2, 2011 Do any of you have experience with the Robocopy option?
36Degrees Posted August 2, 2011 Posted August 2, 2011 I'd try this - 1) Export a list of usernames from AD to a text file 2) Write a script which: a) maps drive Y: to \\hosea\d$\users\students\ b) maps drive Z: to \\Server2\userbackup\Year11\ c) Reads in username from text file d) Creates new folder Z:\username e) Robocopy Y:\username to Z:\username such that it moves the data
Admiral208 Posted August 2, 2011 Posted August 2, 2011 thinking ahead for next time, I would create a folder called Files, or Work or similar inside each of the students folders that they can use to save work then all you would need to do is copy the entire folder structure to your backup then do a search for folders called work and delete them, therefore keeping the root folder of the student intact. i.e create \\hosea\d$\users\students\%username%\Files In AD alter the location of the the home drive to this new folder and it wont look any different to the students.
laserblazer Posted August 2, 2011 Posted August 2, 2011 This may be a daft way to do it but I map each year group folder and then do a search of all files on that mapped drive. I can then sort and block copy/delete. It's the only way I have found to deal with long files names.
Haux Posted August 2, 2011 Author Posted August 2, 2011 Sorry the reason we can't delete the root folder is because we want to keep the permissions on said folder.
Haux Posted August 3, 2011 Author Posted August 3, 2011 What do people think to.... Using a script to copy a list of the student's names taken from AD to xfer files from A to B. Then is there a way I can use Robocopy to delete the content's of multiple folders but leave the main header folder? e.g. Leave Joe.Blogg but remove all of it's contents?
ChrisH Posted August 3, 2011 Posted August 3, 2011 (edited) This could be a fairly simple script and as such I have put something together for you. It only currently looks at your folders and echos the robocopy command it would use. It only needs one more line of code to be live. Use this at your own risk! You need to decide what robocopy options you need as I just guessed so try on one student folder first by using robocopy at the cmd line. Please run it from the command line for testing eg cscript movefiles.vbs unless you like pressing ok on a dialogue box for the number of student folders you have. Save this code into a folder called movefiles.vbs (or whatever you like) Set FSO = CreateObject("Scripting.FileSystemObject") Const ORIGINAL_ROOT = "D:\Test" ' Source folder Const DEST_ROOT = "D:\Test2" ' Destination folder Set objFolder = FSO.GetFolder(ORIGINAL_ROOT) Set objShell = CreateObject("WScript.Shell") strCmdLine = "" Const ROBO_OPTIONS = "/e /zb /copyall /r:3 /w:15 /MOVE" ' Change these robocopy switches to what you want For Each Subfolder in objFolder.SubFolders Wscript.Echo "Currently looking at: " & Subfolder.Path & VbCrLf ' For testing to show which folder strCmdLine = "Robocopy " & Subfolder.Path & "\*.* " & DEST_ROOT & "\" & subfolder.name & " " & ROBO_OPTIONS ' to build the cmd line that will run Wscript.echo strCmdLine ' to show the cmd line that will run 'ShowSubFolders Subfolder Next Let me know how you get on and I will help you finish it if you want to use it. Edited August 3, 2011 by ChrisH Code mistake 3
featured_spectre Posted August 3, 2011 Posted August 3, 2011 Awesome script and saved for future reference for myself!
ChrisH Posted August 3, 2011 Posted August 3, 2011 Tbh I am having trouble finding a command line that leaves the student folder in place but it must be doable. Robocopy is the best choice for doing loads of files like this but if needs be, you can use something else.
ChrisH Posted August 3, 2011 Posted August 3, 2011 Why exactly do you want to keep the folders btw? Is it for YR11 going into 12? but what about 13? People who resit? Anyway I can get the folder to move but it would have to be recreated so I was wondering because of permissions etc. Running NTFSFIX would sort them in about 2 mins though. Ps can you tell I'm bored
Haux Posted August 3, 2011 Author Posted August 3, 2011 Thanks mate! I'm testing out the code now. I can't get it to transfer the top folder over though? It just copies the contents? Thanks
ChrisH Posted August 3, 2011 Posted August 3, 2011 (edited) I wanted it to do that on mine but it didn't (Windows 7 64) what OS are you using? This version copies the whole folder over but it removes the folder from source. I have put a line in to recreate it but have commented it out as well as the execution of the robocopy: Set FSO = CreateObject("Scripting.FileSystemObject") Const ORIGINAL_ROOT = "D:\Test" ' Source folder Const DEST_ROOT = "D:\Test2" ' Destination folder Set objFolder = FSO.GetFolder(ORIGINAL_ROOT) Set objShell = CreateObject("WScript.Shell") strCmdLine = "" strCurrentFolder = "" Const ROBO_OPTIONS = "/e /zb /copyall /r:3 /w:15 /MOVE" ' Change these robocopy switches to what you want For Each Subfolder in objFolder.SubFolders strCurrentFolder = subfolder.path Wscript.Echo "Currently looking at: " & Subfolder.Path & VbCrLf ' For testing to show which folder strCmdLine = "Robocopy " & Subfolder.Path & "\ " & DEST_ROOT & "\" & subfolder.name & " " & ROBO_OPTIONS ' to build the cmd line that will run Wscript.echo strCmdLine ' to show the cmd line that will run 'ObjShell.Run StrCmdLine,1,True 'run robocopy 'FSO.CreateFolder strCurrentFolder 'Recreate the folder Next Edited August 3, 2011 by ChrisH
Haux Posted August 3, 2011 Author Posted August 3, 2011 It does exactly the same on my end - Also Windows 7 Pro x64! The thing with it deleting folders & recreating is that I lose the permission structure on the folders :/
ChrisH Posted August 3, 2011 Posted August 3, 2011 Yes I mentioned that. That is why I said look at NTFSFIX as you will be able to restore you permissions to what you want them to be in under 5 mins, very easy to use and I use it for all my bulk permission changing as you can define your permissions for the normal domain admins, system and then use the folder name to define access to the user.
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