none
Robocopy copying from a text file. RRS feed

  • Question

  • First of all thanks in advance.  I have scoured this forum and have found many many answers to many question.  But I am having problems with this.

    I'm not  picky if it is VB powershell or batch file does matter to me.

    We have shares which are located at \\servername\home\username.  We are getting rid of home folders and moving to One Drive.  I would like to copy the files from share name (above) to userprofile\OneDrive - <name with spaces>.  Here is the tricky part.  We are not copying everything. Only folders and files with less than 200 character. Then we will run another robocopy to copy the remaining to userprofile\longfilenames. Once we figure out how to read from a text file and copy that Im fairly confident i can figure the other script.

    Here is a sample of what is in the text file Files.txt

    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\audio\LTA_03_a.mp3
    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\audio\LTA_06_b.mp3
    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\audio\LTA_06_a.mp3
    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\audio\LTA_01_a.mp3

    Here is what i have so far

    for %%a in (Files.txt) do robocopy \\mabosnas03\home\%username%\  "%USERPROFILE%\OneDrive - Company name\Documents1" %%a /S /TEE
    

    and the results

    :\Users\jszesnat\LongFileNames\OneDriveScript>robocopy \\mabosnas03\home\jszesnat\  "C:\Users\jszesnat\OneDrive - Company name\Documents1" Files.txt /S /TEE

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

      Started : Wednesday, September 14, 2016 11:23:15 AM
       Source : \\mabosnas03\home\jszesnat\
         Dest : C:\Users\jszesnat\OneDrive - Company name\Documents1\

        Files : Files.txt

      Options : /TEE /S /DCOPY:DA /COPY:DAT /R:1000000 /W:30

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

              New Dir          0    \\mabosnas03\home\jszesnat\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Alves 2e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Alves 2e\Alves_ALT\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Anderson 8e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Anderson 8e\from manuscript\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Campbell 3e (pop)\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Campbell 3e (pop)\ALGs\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Campbell 3e (pop)\IP\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Campbell 3e (pop)\LGs\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Campbell 3e (pop)\playlists\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Campbell 4e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth 10e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\from Nora\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\from Nora\mfa_revisions\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\from Nora\mfa_revisions\css\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\from Nora\__MACOSX\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\from Nora\__MACOSX\mfa_revisions\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\from Nora\__MACOSX\mfa_revisions\css\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\css\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\audio\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\mia\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\files\video\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\img\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Duckworth RC\MFA\js\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Hoffer 4e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Hoffer 4e\Fusion contracts from 3e ALGs\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Music Education RC\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Music History RC\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Titon 3e Shorter\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Titon 5e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Titon 5e\RC\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\World Music Resource Center\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\World Music Resource Center\flashcards\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\World Music Resource Center\screens\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Wright 5e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Wright Simms Media Update 1e\
              New Dir          0    \\mabosnas03\home\jszesnat\My Documents\Music\Wright Simms Media Update 1e\from Sue\

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

                   Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :        42        42         0         0         0         0
       Files :         0         0         0         0         0         0
       Bytes :         0         0         0         0         0         0
       Times :   0:00:00   0:00:00                       0:00:00   0:00:00
       Ended : Wednesday, September 14, 2016 11:23:15 AM

    Wednesday, September 14, 2016 3:30 PM

Answers

  • Unfortunately we can only provide general guidance rather than specific support for your specific project. For that, we'd recommend hiring a consultant.

    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Szesnat Wednesday, September 14, 2016 4:51 PM
    Wednesday, September 14, 2016 4:48 PM
    Moderator

All replies

  • This is not a robocopy support forum, but read the syntax for robocopy carefully:


          Usage :: ROBOCOPY source destination [file [file]...] [options]
    
         source :: Source Directory (drive:\path or \\server\share\path).
    destination :: Destination Dir  (drive:\path or \\server\share\path).
           file :: File(s) to copy  (names/wildcards: default is "*.*").
    

    Note that the file part of the syntax cannot include paths, which is what you're trying to do here. The paths are specified in the source and destination part of the syntax.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, September 14, 2016 3:43 PM
    Moderator
  • If you search you will find many examples of how to move files to OneDrive.  You must also filter out special characters or the sync will fail.


    \_(ツ)_/

    Wednesday, September 14, 2016 4:00 PM
  • Thanks Bill.  I do know this isnt a robocopy forum but a scripting forum.  I was trying to script with robocopy to get what i wanted done.  I apologize i didnt know there is a separate forum for Robocoy.

    I appreciate the fast response.  I did find this https://powershell.org/forums/topic/powershell-robocopy/

    If this isnt the proper place for this question i will move on.  For some reason the script below doesnt insert excluded files.  ( going about it a different way. I wrote a powershell script that gets all of the names at a certain length and store in a txt file called file.txt. I want powershell to add that to the robocopy syntax.

    $pathToScan = "\\mabosnas03\home\$env:username" 
    $oneDrivePath = "$env:userprofile\OneDrive - Company Name\test"
    
    
    $src = $pathToScan
    $dest = $oneDrivePath
    $excludedfiles = "`"$((Get-Content "$env:userprofile\LongFileNames\OneDriveScript\RFiles.txt") -join '" "')`""
    
     
    robocopy.exe $src $dest "/S" "/XF" $excludedfiles "/R:3" "/W:3" "/TEE"

    But what it does is just copies everything. 

    it does see the exec files but my as jrv said  i need to filter the txt file out better.

    Windows PowerShell
    Copyright (C) 2015 Microsoft Corporation. All rights reserved.


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

      Started : Wednesday, September 14, 2016 12:42:11 PM
       Source : \\mabosnas03\home\jszesnat\
         Dest : C:\Users\jszesnat\OneDrive - Company Name\test\

        Files : *.*

    Exc Files : My
                Documents\Music\Duckworth
                RC\MFA\files\audio\me26.mp3 My
                Documents\Music\Duckworth
                RC\MFA\files\audio\me25.mp3 My
                Documents\Music\Duckworth
                RC\MFA\files\audio\me28.mp3 My

    Any help would be appreciated.  Again my thanks and apologize if this is the wrong place to ask.



    • Edited by Szesnat Wednesday, September 14, 2016 4:45 PM
    Wednesday, September 14, 2016 4:44 PM
  • Unfortunately we can only provide general guidance rather than specific support for your specific project. For that, we'd recommend hiring a consultant.

    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Szesnat Wednesday, September 14, 2016 4:51 PM
    Wednesday, September 14, 2016 4:48 PM
    Moderator
  • Thanks Bill.
    Wednesday, September 14, 2016 4:51 PM