Announcement

Collapse
No announcement yet.

Copy to multiple locations

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy to multiple locations

    I will start by stating-- I do not have any experence with scripting other than basic batch files.

    What I am trying to accomplish is copy single file to multiple locations (400)

    The script I have been using works... but it copies item twice
    Once at desired location and once 1 directory above

    I would prefer to have it only copy to the end location

    Here is the script
    for /R O:\share\dir1\dir2\dir3 %a in (.) do copy c:\stuff\*.txt %a

    the path to copy to looks like this

    O:\share\101-jm\01-private\desktop\jm\desktop

    copied file shows up at jm dir and at desktop level (the last one)

    The correct location is the desktop

    Does anyone know how to correct this script to make it perform the desired way?

  • #2
    Re: Copy to multiple locations

    My opinion is use either RoboCopy or XXCopy. Both have numerous options in file copying and integrity checking.
    Mohan Mathew[VU3MMU]
    MCITP [AD]

    Comment


    • #3
      Re: Copy to multiple locations

      Maybe I am missing something
      Do not see robocopy as the answer (could be wrong)


      Trying to copy c:\*.* to drive\share\dir\user\dir

      The variable is the user (this is not their profile) it is a redirected desktop

      400 variables

      The issue is
      my current script double copies
      one copy at the first dir and one at the second Dir

      Thanks in advance!!

      Comment


      • #4
        Re: Copy to multiple locations

        Can't you run it as a logonscript?
        Marcel
        Technical Consultant
        Netherlands
        http://www.phetios.com
        http://blog.nessus.nl

        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
        "No matter how secure, there is always the human factor."

        "Enjoy life today, tomorrow may never come."
        "If you're going through hell, keep going. ~Winston Churchill"

        Comment


        • #5
          Re: Copy to multiple locations

          Possible--
          would still have to "recognize" 400 different locations


          drive\share\dir\variable\dir

          Am I missing something simple....?

          Comment


          • #6
            Re: Copy to multiple locations

            You might wait for Rems, our scripting guru
            Marcel
            Technical Consultant
            Netherlands
            http://www.phetios.com
            http://blog.nessus.nl

            MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
            "No matter how secure, there is always the human factor."

            "Enjoy life today, tomorrow may never come."
            "If you're going through hell, keep going. ~Winston Churchill"

            Comment


            • #7
              Re: Copy to multiple locations

              Thanks..
              I appreciate the assistance!

              Comment


              • #8
                Re: Copy to multiple locations

                The important part of the script below is in bold.
                The Dir command is used with the switches /AD /B to output the names (%%*) of all the folders (just folders), that are the first subfolders in the %destRoot% path.
                The desired destination to copy the files to will then be the %destRoot%\ plus %%* (=user's folder) plus "\desktop" path.
                Code:
                @echo off & Title Copying files
                
                Setlocal
                
                Set "sourcefiles=c:\test\*.txt"
                
                Set "destRoot=O:\share\101-jm\01-private\desktop"
                Set "subfolder=desktop" in user's folder
                
                echo/Please wait....
                >%temp%.\cpytmp (
                
                echo/%date% %time% & echo/
                echo/Files to copy, & echo/
                xcopy /Y /C /L "%sourcefiles%" "%sourcefiles%\."/I
                echo/
                
                For /F "delims=" %%* in ('dir "%destRoot%\." /AD /B 2^>nul') DO (
                   If exist "%destRoot%\%%*\%subfolder%" (
                   echo/- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                   2>nul (xcopy /Y /C /Q "%sourcefiles%" "%destRoot%\%%*\%subfolder%")
                   echo/    -^> %%*\%subfolder%
                   )
                )
                
                )
                >>%temp%.\cpytmp (echo/)
                >nul (start ""/b notepad.exe "%temp%.\cpytmp" &&(
                ping.exe 127.0.0.1 -n 3) &&Del "%temp%.\cpytmp")
                
                endlocal
                This batch writes also a quick log, you can skip the lines causing this (they are in green) if you want.


                \Rems

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment


                • #9
                  Re: Copy to multiple locations

                  Rems--
                  Thanks!... stiil tring to figure out the script..
                  Not the quickest at this...


                  Set "destRoot=O:\share\101-jm\01-private\desktop"
                  Set "subfolder=desktop" in user's folder
                  -------
                  O:\share\101-jm\01-private\desktop\username\desktop

                  not sure what I am missing

                  Comment


                  • #10
                    Re: Copy to multiple locations

                    Rems--

                    Thank you
                    Iworks great-- just tripped over my own feet making it work!

                    Thanks again!

                    Comment

                    Working...
                    X