Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 04, 2015, 04:04:07 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC  (Read 5057 times)

scottchamings

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Hi,

I would love some code that will go through C:\Documents and Settings and for each user copy their My Documents, Favorites and Desktop folder to another folder structure retaining their username.

eg

copy C:\Documents and Settings\Scott\My Documents to %Path I specify%\Scott\My Documents

I often need to do this and manual copying is just so slow and clumbersome...

Thanks

Scott


belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #1 on: September 04, 2008, 10:32:17 AM »
Scott,

Might give this a try. I have been using it for a while and it works very well.

http://www.karenware...ols/ptreplicator.asp

-belkira

scottchamings

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #2 on: September 04, 2008, 11:09:52 AM »
This is close but not quite.  I need something that does not need me to select the folders under each of the users names or even know them in advance.

Basically need it to parse all the user ids, start a copy but keep the path structure intact and only copy the My Documents, Favorites and Desktop folders and down for each of the users, even though there might be heaps more folders under each user (Temp etc) which I dont want...

VideoInPicture

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 467
    • View Profile
    • Circle Dock
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #3 on: September 04, 2008, 02:48:37 PM »
Attached is a VB Script file that will do what you specified. Just double-click the .vbs file and it will automatically copy the selected folders. Change the strDestination path to change where the copied files are placed.

From your other thread about file copying, I assume you are going to be using this in a corporate environment so a VB Script file is your best choice since it will run on all computers without the need for more software. See the comments in the code for more details.

Quote
Code: Text
  1. ' CopyUserFiles.vbs
  2. ' VBScript for copying the Document and User files to another directory
  3. ' Coded for Windows XP but can be adapted for 2000 / Vista by changing
  4. ' FavoritesFolder, DesktopFolder, MyDocumentsFolder, strFilePath, and strDestination to suit your needs
  5. '
  6. ' Program runs silently while copying. It may take a while to copy large files.
  7. ' A messagebox will pop up when finished.
  8. '
  9. ' Author: Eric Wong http://circledock.wikidot.com
  10. ' VideoInPicture@gmail.com
  11. ' Version 1.0 - 4th September 2008
  12. ' ----------------------------------------------------------
  13.  
  14. Option Explicit
  15.  
  16. Dim objFSO_DIR, objFolder, objCopyFolder, colSubfolders, objSubfolder
  17. Dim objFSO, objFileCopy
  18. Dim strFilePath, strDestination
  19. Dim fileChecker, objShell
  20. Const OverWriteFiles = True
  21.  
  22. Const FavoritesFolder = "\Favorites"
  23. Const DesktopFolder = "\Desktop"
  24. Const MyDocumentsFolder = "\My Documents"
  25.  
  26. strFilePath = "C:\Documents and Settings"
  27. strDestination ="C:\New Documents and Settings"
  28.  
  29. Set objFSO = CreateObject("Scripting.FileSystemObject")
  30. Set fileChecker = CreateObject("Scripting.FileSystemObject")
  31. Set objShell = CreateObject("Shell.Application")
  32. 'Set objCopyFolder = CreateObject("Shell.Application")
  33.  
  34. objFSO.CreateFolder(strDestination)
  35.  
  36. Set objFSO_DIR = CreateObject("Scripting.FileSystemObject")
  37. Set objFolder = objFSO_DIR.GetFolder(strFilePath)
  38. Set colSubfolders = objFolder.Subfolders
  39.  
  40. 'This is the core of the file copying process
  41. For Each objSubfolder in colSubfolders
  42.     Set objFolder = objFSO.CreateFolder(strDestination & "\" & objSubfolder.Name)  
  43.  
  44.     If fileChecker.FolderExists(objSubfolder & FavoritesFolder) = True Then
  45.        fileChecker.CopyFolder objSubfolder & FavoritesFolder, objFolder & FavoritesFolder, OverWriteFiles
  46.     End If
  47.  
  48.     If fileChecker.FolderExists(objSubfolder & DesktopFolder) = True Then
  49.        fileChecker.CopyFolder objSubfolder & DesktopFolder, objFolder & DesktopFolder, OverWriteFiles
  50.     End If
  51.  
  52.     If fileChecker.FolderExists(objSubfolder & MyDocumentsFolder) = True Then
  53.        fileChecker.CopyFolder objSubfolder & MyDocumentsFolder, objFolder & MyDocumentsFolder, OverWriteFiles
  54.     End If
  55. Next
  56.  
  57. WSCript.Echo "Finished copying selected folders from " & strFilePath & " to " & strDestination
  58. Wscript.Quit
  59.  
  60.  
Author of Circle Dock: http://circledock.wikidot.com
Author of Video In Picture: http://videoinpicture.wikidot.com
Author of Webcam Signature: http://webcamsignature.wikidot.com
Author of Easy Unicode Paster: http://easyunicodepaster.wikidot.com

scottchamings

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #4 on: September 04, 2008, 05:19:01 PM »
awesome, thanks, will try out later today on a couple of PCs I need to reimage....

VideoInPicture

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 467
    • View Profile
    • Circle Dock
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #5 on: September 04, 2008, 05:41:00 PM »
Just a note: ensure that the folder you specify to copy to doesn't already exist because the program is not set up to overwrite an existing folder and will throw an error. It can be modified to overwrite an existing folder if that is what the goal is.
Author of Circle Dock: http://circledock.wikidot.com
Author of Video In Picture: http://videoinpicture.wikidot.com
Author of Webcam Signature: http://webcamsignature.wikidot.com
Author of Easy Unicode Paster: http://easyunicodepaster.wikidot.com

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,219
    • View Profile
    • Coding Snacks by Lanux128
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #6 on: September 04, 2008, 08:29:53 PM »
cool script! i was going to suggest XXCOPY but i guess with Eric's script, one need not to fiddle with switches. :)