Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: copy 3 files to every directory in a certiain folder  (Read 6350 times)

0 Members and 1 Guest are viewing this topic.

ehsan_08

    Topic Starter


    Rookie

    copy 3 files to every directory in a certiain folder
    « on: August 20, 2008, 02:07:37 PM »
    lets say i have about 10 folders in C:\files\
    and i have 3 files that needs to be copied to every of those 10 folders, any idea how?
    and let me know if i can make a exception for a folder to not be cpoied ;D


    maybe something like:
    Code: [Select]
    set /p dir= DIR
    copy "1.txt+2.txt+3.txt "%dir%

    ??????????????????


    thanks

    fireballs



      Apprentice

    • Code:Terminal
    • Thanked: 3
      Re: copy 3 files to every directory in a certiain folder
      « Reply #1 on: August 20, 2008, 05:06:36 PM »
      the code you've got should work just without the quotation marks...
      also unless you want to change the directory you're copying into then there's no need for the /p argument.

      Code: [Select]
      set dir= DIR
      copy 1.txt+2.txt+3.txt %dir%

      keep us informed

      FB
      Next time google it.

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: copy 3 files to every directory in a certiain folder
      « Reply #2 on: August 20, 2008, 07:01:30 PM »
      Quote
      Lets say i have about 10 folders in C:\files\
      and i have 3 files that needs to be copied to every of those 10 folders, any idea how?

      Code: [Select]
      @echo off
      set folder=c:\files
      for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (
      copy 1.txt %folder%\%%v
      copy 2.txt %folder%\%%v
      copy 3.txt %folder%\%%v
      )
         

      Using code like copy "1.txt+2.txt+3.txt "%dir% will append the text files into a single file labeled 1.txt

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      fireballs



        Apprentice

      • Code:Terminal
      • Thanked: 3
        Re: copy 3 files to every directory in a certiain folder
        « Reply #3 on: August 20, 2008, 07:05:22 PM »
        I'm such a tard i was so lost in using copy i forgot what the original problem was  >:( grrrr

        FB
        Next time google it.

        ehsan_08

          Topic Starter


          Rookie

          Re: copy 3 files to every directory in a certiain folder
          « Reply #4 on: August 20, 2008, 08:53:18 PM »
          no luck, i got this:


           :-\ :-[ :-[ :-[ :-[

          Dias de verano

          • Guest
          Re: copy 3 files to every directory in a certiain folder
          « Reply #5 on: August 21, 2008, 12:19:35 AM »
          I expect the target folder name needs quote marks around it, judging by that screen shot.

          Code: [Select]
          copy 1.txt "%folder%\%%v"
          ... etc








          ehsan_08

            Topic Starter


            Rookie

            Re: copy 3 files to every directory in a certiain folder
            « Reply #6 on: August 21, 2008, 12:57:09 AM »
            thanks, that worked!!

            now to improve it a bit more, if u will help ;D
            anyway to make it ask u for the location, so i don'y have to edit the bat everytime, instead the bat asks me for the dir

            i tried this, doesn't work:
            Code: [Select]
            @echo off
            set /p location= Type in the directory please.
            set folder= %location%
            for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (

            copy 1.txt "%folder%\%%v"
            copy 2.txt "%folder%\%%v"
            copy 3.txt "%folder%\%%v"
            )



            pause

            EDIT:btw,
            about this part:

               copy 1.txt "%folder%\%%v"
               copy 2.txt "%folder%\%%v"
               copy 3.txt "%folder%\%%v"

            one file's name has an space in the name of it, so it says not found, but when i replaced with a _
            it worked
            anyway to not put _?

            Dias de verano

            • Guest
            Re: copy 3 files to every directory in a certiain folder
            « Reply #7 on: August 21, 2008, 01:51:35 AM »
            That screen shot is much too big. Making scroll bar appear.

            The file names are 1.txt 2.txt and 3.txt. I do not see any spaces.

            Do not understand about _ An underscore _ is not a space.

            When you say "doesn't work", please give more details.

            Code: [Select]
            @echo off
            set /p location= Type in the directory please.
            set folder= %location%

            Remove the spaces after the = signs.







            ehsan_08

              Topic Starter


              Rookie

              Re: copy 3 files to every directory in a certiain folder
              « Reply #8 on: August 21, 2008, 02:42:23 AM »
              i see, it worked ;)
              ty
              sorry for that huge pic

              and btw, the names of those txt files, those were the samples, tests out

              wut i mean, i have 2 files, lets say "Dos is cool.txt"
              it won't find it, since theirs space in the filesname ???

              ehsan_08

                Topic Starter


                Rookie

                Re: copy 3 files to every directory in a certiain folder
                « Reply #9 on: August 21, 2008, 01:23:37 PM »
                PLEASE HELP!!

                its almost done!!!
                im having one problem, when u put a DIR to go on, if the dir has space in it, it won;t work?

                for ex: C:\files to backup\
                won't work cuz of the space in em

                but this:
                C:\filestobackup\
                works?

                any idea??

                fireballs



                  Apprentice

                • Code:Terminal
                • Thanked: 3
                  Re: copy 3 files to every directory in a certiain folder
                  « Reply #10 on: August 21, 2008, 01:27:31 PM »
                  put it in quotes...

                  Code: [Select]
                  for ex: "C:\files to backup\"
                  FB
                  Next time google it.

                  ehsan_08

                    Topic Starter


                    Rookie

                    Re: copy 3 files to every directory in a certiain folder
                    « Reply #11 on: August 21, 2008, 02:08:32 PM »
                    Quote
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.
                    The syntax of the command is incorrect.


                    heres the code:
                    Code: [Select]
                    set /p location=Type in the directory please (ex. C:\desktop\uploads\)  :
                    set folder=%location%
                    for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (

                    copy xxxxxx "%folder%\%%v"
                    copy xxxxxx "%folder%\%%v"
                    copy xxxxxx "%folder%\%%v"
                    )




                    echo Finished!
                    echo.
                    pause

                    Dias de verano

                    • Guest
                    Re: copy 3 files to every directory in a certiain folder
                    « Reply #12 on: August 21, 2008, 02:17:26 PM »
                    works fine on my system.

                    What does xxxxxx represent? If it represents filenames with spaces, then you should know by now what to do.


                    ehsan_08

                      Topic Starter


                      Rookie

                      Re: copy 3 files to every directory in a certiain folder
                      « Reply #13 on: August 21, 2008, 02:24:48 PM »
                      im sorry
                      the xxxxx are for some files, if i put the real name, might be a spam in here :-[

                      im having trouble with the folder name, when it asks for a folder,
                      the folder:
                      C:\files backup\
                      won't work, and when i put ""

                      here, the real file:

                      try it on a folder that has spaces
                      « Last Edit: August 21, 2008, 06:42:14 PM by Zylstra »

                      Dias de verano

                      • Guest
                      Re: copy 3 files to every directory in a certiain folder
                      « Reply #14 on: August 21, 2008, 02:31:36 PM »
                      I am having great difficulty understanding what you are trying to do.

                      Why have you posted a link to an exe file? I though this was a batch file forum.

                      This is turning into one of "those" threads.

                      « Last Edit: August 21, 2008, 02:42:42 PM by Dias de verano »