+ Post New Thread
Results 1 to 6 of 6
Windows Thread, Copying files off PCs in Technical; Hello all, I need to copy a specific folder off a number of different PCs. I would like to do ...
  1. #1
    Robot's Avatar
    Join Date
    Oct 2009
    Location
    Leeds
    Posts
    82
    Thank Post
    23
    Thanked 7 Times in 7 Posts
    Rep Power
    12

    Copying files off PCs

    Hello all,


    I need to copy a specific folder off a number of different PCs. I would like to do this via a script if possible.

    The only problem I can see is that the folder is in
    C:\documents and settings\user name\...rest of string...

    How would I write something that gets me through that "user name" folder into the directory below, regardless of what that "user name" folder is named?


    Thanks.
    Last edited by Robot; 19th March 2010 at 02:55 PM.

  2. #2

    Join Date
    Feb 2007
    Location
    Berks
    Posts
    14
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    %username%

  3. #3

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    65
    %username% returns the logged on username though, it won't walk through directories in the documents and settings folder. Are you going to be running the script manually at each PC or do you want to do it remotely?

    You'll want something like a for loop in the script to walk through the directories -

    cd C:\documents and settings\
    for %%I /D in (*) do copy "C:\documents and settings\%%I\yourstring\yourfile.txt" "\\server\folder"

  4. Thanks to OutToLunch from:

    Robot (19th March 2010)

  5. #4
    Robot's Avatar
    Join Date
    Oct 2009
    Location
    Leeds
    Posts
    82
    Thank Post
    23
    Thanked 7 Times in 7 Posts
    Rep Power
    12
    Quote Originally Posted by OutToLunch View Post
    %username% returns the logged on username though, it won't walk through directories in the documents and settings folder. Are you going to be running the script manually at each PC or do you want to do it remotely?

    You'll want something like a for loop in the script to walk through the directories -

    cd C:\documents and settings\
    for %%I /D in (*) do copy "C:\documents and settings\%%I\yourstring\yourfile.txt" "\\server\folder"
    I would be wanting to run it remotely but only to select PCs in the domain, so would also need to target them somehow.

  6. #5

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    something like this? Not sure if you have a known list of PCs (this assumes you have an it's in a plain text file) or if you're going to query all PCs in an OU in AD or whatever but I hope this gets you started.

    Code:
    'what's the folder to look for
    sFolderName="Application Data\Maple\13"
    'where do you want it copying to
    sDestination="\\cs-srochfor-01\tmp\"
    
    dim sComputers()
    dim iComputers
    icomputers=0
    
    set oFSO=createobject("scripting.filesystemobject")
    
    GetComputerList
    QueryComputers
    
    sub GetComputerList
      'simple list of PCs; read it and store in array
      sList="c:\temp\pcs.txt"
      set oFile=ofso.opentextfile(sList)
      do while not oFile.atendofstream
        sComputer=oFile.readline
        iComputers=iComputers + 1
        redim preserve sComputers(iComputers)
        sComputers(iComputers)=sComputer
      loop
      oFile.close
    end sub
    
    sub QueryComputers
      for each sComputer in sComputers
        if sComputer<>"" then
          'get the root of D&S
          sPath="\\" & sComputer & "\c$\documents and settings\"
          set oFolder=ofso.getfolder(sPath)
          for each oSubFolder in oFolder.subfolders
            'look at each user folder
            if ofso.folderexists(sPath & oSubFolder.Name & "\" & sFolderName) then
              'the folder we want exists so make a suitable folder on the destination machine - first for computer
              if not ofso.folderexists(sDestination & sComputer) then ofso.createfolder sDestination & sComputer
              'and now for user
              if not ofso.folderexists(sDestination & sComputer & "\" & oSubFolder.Name) then ofso.createfolder sDestination & sComputer & "\" & oSubFolder.Name
              'copy everything
              ofso.copyfolder sPath & oSubFolder.Name & "\" & sFolderName,sDestination & sComputer & "\" & oSubFolder.Name & "\"
            end if
          next
        end if
      next
    end sub

  7. Thanks to srochford from:

    Robot (21st March 2010)

  8. #6
    Robot's Avatar
    Join Date
    Oct 2009
    Location
    Leeds
    Posts
    82
    Thank Post
    23
    Thanked 7 Times in 7 Posts
    Rep Power
    12
    Thanks very much! I will have a look at this on Monday

SHARE:
+ Post New Thread

Similar Threads

  1. Copying large video files over a network connection
    By randle in forum Wireless Networks
    Replies: 2
    Last Post: 24th March 2009, 11:27 PM
  2. Problems copying files
    By DeanD in forum Windows
    Replies: 7
    Last Post: 13th April 2008, 04:26 PM
  3. copying files and dirs in xp recovery console
    By torledo in forum Windows
    Replies: 6
    Last Post: 18th March 2008, 02:28 PM
  4. Pulling copying fails - push copying works
    By SimpleSi in forum Windows
    Replies: 1
    Last Post: 3rd March 2008, 02:29 PM
  5. Copying Files Takes Forever
    By enjay in forum Windows Vista
    Replies: 7
    Last Post: 26th September 2007, 09:41 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
  •