+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, Script to copy a file or folder to multiple users Documents folder. in Coding and Web Development; Hi, I am just trying to teach my self some basic scripts, am totally new to coding. What i am ...
  1. #1

    Join Date
    Oct 2011
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Script to copy a file or folder to multiple users Documents folder.

    Hi,

    I am just trying to teach my self some basic scripts, am totally new to coding. What i am looking to do is to comprise a script to copy files or folder from one location to all users "my documents" folder.

    currently this is on windows 2008 r2 platform.

    the files needed to be copied would be on a server eg \\fileserver\Filefolder
    the folders needing the files are laid out like this \\fileserver\redirected$\Pupils\2013start\JBloggs1 3\My Documents
    \\fileserver\redirected$\Pupils\2013start\TBloggs1 3\My Documents

    so my problem is how do i get the script to copy to all the usernames "my documents folder" without manually specifying the unc path of all of them. Also does the fact there is a space in my documents affect the layout of the script.

    the users dont have a home path specified in AD, they are redirected through Group Policy.
    Last edited by Menov321; 31st January 2014 at 11:51 AM.

  2. #2


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    7,059
    Thank Post
    232
    Thanked 926 Times in 795 Posts
    Rep Power
    309
    might be easier to use gpp and tell it to copy file from a to my documents for the group 2013 or just use a logon script copy "\\server\share\source.txt" "%homedrive%\my documents\source.txt"

  3. #3
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,497
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    76
    I had to do this recently. Here's (roughly) what I did:

    Open CMD prompt
    Type dir >names.txt to get a list of all the students' folders
    Open the text file in Excel
    Use "Concatenate" command to create a load of commands which read something like
    copy C:\Folders\Files\*.* D:\Users\Students\%Names%\
    Copy and paste the Excel data into Notebook
    Save as .bat
    Run it

  4. 2 Thanks to enjay:

    IWDave (31st January 2014), Menov321 (31st January 2014)

  5. #4

    Join Date
    Oct 2011
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    thanks so much to sted and enjay... I tried enjays method and it worked a charm

  6. #5

    Join Date
    Jul 2012
    Location
    Boerne Texas USA
    Posts
    45
    Thank Post
    0
    Thanked 9 Times in 9 Posts
    Rep Power
    6
    dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(!(use rAccountControl:1.2.840.113556.1.4.803:=2))(homedi rectory=*server1*))" -limit 500 | dsget user -hmdir -samid -c > out.txt
    for /f "skip=1 tokens=1,2" %%a in (out.txt) do copy \\server\share\file %%a\folder\file



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 0
    Last Post: 23rd March 2012, 12:43 PM
  2. Script to copy .bak files with todays date to nas
    By itgeek in forum MIS Systems
    Replies: 3
    Last Post: 15th February 2011, 09:03 PM
  3. Replies: 4
    Last Post: 11th February 2011, 05:36 PM
  4. Copy New file from A to B
    By itgeek in forum Scripts
    Replies: 11
    Last Post: 1st December 2009, 03:38 PM
  5. Replies: 6
    Last Post: 20th October 2005, 07:48 PM

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
  •