Results 1 to 13 of 13
  1. #1
    New Lounger
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't copy folder onto network T: drive

    Code:
    Set /P LogonName=Please enter the user's logon (The one you used to log onto the computer)^>
    
    
    Set /P DriveName=Please tell me your name exactly how it appears in T:Drive ****PLEASE REMEMBER to use - between words e.g Bill-Gates^>
    
    
    xcopy /y C:\Users\%LogonName%\Documents\ "T:\Office Admin Data\Individual Staff Folders\%DriveName%\Backup"
    
    
    Echo The files have been copied.
    pause
    cls


    Basically I want Staff members to easily be able to copy there docs onto our Shared T: Drive.

    No errors come up, in fact it tells me items have been copied but when i searched the folder nothing is inside it...

    Can't wrap my head around it, i had it working copying and pasting locally...
    Last edited by Mr Galactus; 2016-03-02 at 09:11.

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,170
    Thanks
    47
    Thanked 978 Times in 908 Posts
    Asking users to enter those details is asking for trouble, they will get something wrong. You are better off automating the process.

    You can find their documents from existing environment variables: %homedrive%%homepath%\Documents
    You can set a local environment variable when you create the user: set SharedTname=Bill-Gates
    Now the whole process is: xcopy /y %homedrive%%homepath%\Documents\ "T:\Office Admin Data\Individual Staff Folders\%SharedTname%\Backup"

    Your existing version should have a trailing backslash so xcopy knows "Backup" is a folder, not a file.
    Doesn't tell xcopy to copy sub-directories (/s).
    Xcopy will copy everything, not just updated / new.

    A better way would be to use Robocopy - built-in - as that only copies new / updated files.
    robocopy %homedrive%%homepath%\Documents\ "T:\Office Admin Data\Individual Staff Folders\%SharedTname%\Backup" /nfl /ndl /r:0

    cheers, Paul

  3. #3
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Could you run the BATch file and replace the XCOPY command with ECHO, and see what it says?

    It's always best to avoid getting users to type anything in!

    Why don't you use the existing environment variable %username% for the user-entered %logonname%?
    There must be a way of getting %drivename% without having to get the users to enter it - even from a table of UserNames and DriveNames, such as:
    Fred Fred_drive
    Tarquin Tarquin_excellent_drive
    and so on...

    ...and what Paul said, slightly more rapidly than me!
    BATcher

    Time prevents everything happening all at once...

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Mr. G.,

    Welcome to the Lounge as a new poster!

    Is it possible that the logon names have spaces?

    If so enclosing the source C:\Users\%LogonName%\Documents\ in quotes should solve the problem. It also wouldn't hurt to specify a file name or pattern, e.g. "C:\Users\%LogonName%\Documents\*.txt"

    You could also eliminate the the first prompt by using %UserName% vs %LogonName%.

    HTH

    Edit: BATcher you slipped in there while I was typing.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    New Lounger
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all your feedback, if you will allow me an hour or so to go through each point ill see what I come up with.

    I 100% agree the user shouldn't be entering their details but since we all work from a network I didn't know how else to get the information.

    I'm really new to Batch editing and spent about 45 minutes writing that out as a first try, really appreciate the support and hope to learn something from the above.

  6. #6
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,170
    Thanks
    47
    Thanked 978 Times in 908 Posts
    What sort of network? AD, homegroup, peer to peer?

    cheers, Paul

  7. #7
    New Lounger
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Paul T View Post
    What sort of network? AD, homegroup, peer to peer?

    cheers, Paul
    Hi Paul,

    It's actually a Local network from our server, this (I assume) is also where the T:drive is located.

    EDIT:

    Paul using your advice above i have managed to get My Docs onto the T Drive however it won't copy the files directly into say T:\Office Admin Data\Individual Staff Folders\Bill Gates\Backup

    It copys a file called documents into T:\Office Admin Data\Individual Staff Folders

    * Side not within this folder is a list of our colleagues name which they have access to, The Login name would be different to this;

    For instance i might log into the computer as "BILL" but within Individual Staff Folders it would be Bill Gates.

    Edit 2: the %SharedTname% isn't relating to anything as it's not connected to there account directly, it's an open file for anyone to go into - It just has their name attached to it.

    I think i could create a list from say 1-10 for the user to input.

    for example:

    1: Bill gates
    2: Steve Jobs
    3: Tim Berners-Lee
    etc.
    Last edited by Mr Galactus; 2016-03-02 at 11:01.

  8. #8
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,170
    Thanks
    47
    Thanked 978 Times in 908 Posts
    Copying to a single file called Documents probably means you have a file called documents, although it may have copied all files to a single file.
    We need to see what command you have run to understand the issue.

    To choose the name automatically, use BATcher's "names in a file" idea.
    for /f %%U in ("T:\Office Admin Data\Individual Staff Folders\namelist.txt") do if %username%==%%N set SharedTname=%%V
    Now you can use xcopy /y "%homedrive%%homepath%\Documents\" "T:\Office Admin Data\Individual Staff Folders\%SharedTname%\Backup\"

    cheers, Paul

  9. #9
    New Lounger
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @Echo off
    Title Test Program by Charles
    Echo Welcome to Charles File copying program.
    Echo This batch file will copy all of your files within "My Documents" and copy them over to your Trive folder.
    pause
    cls
    Echo This may take several minutes depending on how many files you have so please be with me.
    pause
    cls

    /f %%U in ("T:\Office Admin Data\Individual Staff Folders\namelist.txt") do if %username%==%%N set SharedTname=%%V
    robocopy %homedrive%%homepath%\Documents\ "T:\Office Admin Data\Individual Staff Folders\%SharedTname%\Backup" /nfl /ndl /r:0


    Echo The files have been copied.
    pause
    cls

    Does not seem to be working, I've created the namelist.txt and inserted my own name which appears within our Individual staff folder but it still doesn't put it into my folder.

  10. #10
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Mr. G.,

    Try it this way:
    Code:
    robocopy "%homedrive%%homepath%\Documents\*.*" "T:\Office Admin Data\Individual Staff Folders\%SharedTname%\Backup\" /nfl /ndl /r:0
    I'd recommend these switches for RoboCopy: /MIR /XJD /R:5 /W:15 /MT:32 /V /NP /NDL /NFL

    HTH
    Last edited by RetiredGeek; 2016-03-02 at 13:08.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. #11
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,170
    Thanks
    47
    Thanked 978 Times in 908 Posts
    Retry 5 times with a 15 second pause? Why? Just let it copy - and log errors if you really want to.
    Mirror is a bad option IMO, it deletes files you accidentally deleted in the source.
    Verbose is no value if you close the copy window when it finishes. More importantly, the users will just be confused.

    cheers, Paul

  12. #12
    New Lounger
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by RetiredGeek View Post
    Mr. G.,

    Try it this way:
    Code:
    robocopy "%homedrive%%homepath%\Documents\*.*" "T:\Office Admin Data\Individual Staff Folders\%SharedTname%\Backup\" /nfl /ndl /r:0
    I'd recommend these switches for RoboCopy: /MIR /XJD /R:5 /W:15 /MT:32 /V /NP /NDL /NFL

    HTH

    '/f' is not recognized as an internal or external command,
    operable program or batch file.


    -------------------------------------------------------------------------------
    ROBOCOPY :: Robust File Copy for Windows
    -------------------------------------------------------------------------------


    Started : 03 March 2016 08:50:04
    Source -
    Dest -


    Files :
    Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30


    ------------------------------------------------------------------------------


    ERROR : Invalid Parameter #1 : "C:\Users\Charles\Documents\*.*"


    Simple Usage :: ROBOCOPY source destination /MIR


    source :: Source Directory (drive:\path or \\server\share\path).
    destination :: Destination Dir (drive:\path or \\server\share\path).
    /MIR :: Mirror a complete directory tree.


    For more usage information run ROBOCOPY /?




    **** /MIR can DELETE files as well as copy them !
    The files have been copied.
    Press any key to continue . . .


    I really appreciate your guys help, as i said i'm new to this and it's all a learning curve - I've found out what /MIR /XJD /R:5 /W:15 /MT:32 /V /NP /NDL /NFL actually means before I put it in.

    I have to agree retrying 5 times and waiting 15 seconds seems useless, could you explain why this is a good idea?

    Thank you again.

    Edit; Also what does *.* relate to?
    Last edited by RetiredGeek; 2016-03-03 at 09:58. Reason: Added NOPARSE tags

  13. #13
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Mr. G.,

    I've been using these options in my daily data backup for years w/o problem. The retries are in case a file is in use by the system it gives it time to be freed up. This us usually not an issue and doesn't affect anything under normal circumstances it's just a fail safe.

    Here's the Batch File that I have fired off by a Scheduled Task every evening at 18:30 (while I watch the news).
    Code:
    Echo Off
    REM  Updated: 12/29/14
    Echo.  -------- Copying BEKDocs to N: drive -------
    Robocopy "G:\BEKDocs" "N:\BEKDocs" /MIR /XJD /R:5 /W:15 /MT:32 /V /NP /NDL /NFL /LOG+:G:\BEKDocs\Batch\BackupTasks\RoboCopy.log 
    Echo.  -------- Copy Completed              -------
    Here's what the log file looks like, less the detail of files:
    Code:
    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows                              
    -------------------------------------------------------------------------------
    
      Started : Wednesday, March 2, 2016 6:30:00 PM
       Source : G:\BEKDocs\
         Dest : N:\BEKDocs\
    
        Files : *.*
    	    
      Options : *.* /V /NDL /NFL /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /NP /XJD /MT:32 /R:5 /W:15 
    
    ------------------------------------------------------------------------------
    .
    .
    .
    ------------------------------------------------------------------------------
    
                   Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :      1477      1477      1477         0         0         0
       Files :     12754        33     12721         0         0        25
       Bytes :  13.591 g 1015.40 m  12.600 g         0         0   16.41 m
       Times :   0:00:43   0:00:08                       0:00:00   0:00:02
       Ended : Wednesday, March 2, 2016 6:30:11 PM
    THe *.* is all file name & all file types. It can be eliminated if you also drop the final \ as seen in my batch file above and depending on the switches used.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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