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

Author Topic: copy all files and folders from current folder  (Read 26818 times)

0 Members and 1 Guest are viewing this topic.

mioo_sara

    Topic Starter


    Intermediate

    copy all files and folders from current folder
    « on: April 01, 2012, 12:12:48 AM »
    hi my friend
     i have a simple question for you profesionals :)

     i found lots of batch files that can copy files or folders but i need a special one
    first of all i have more than 3000 folders including subfolder in my multi hard drives so i dont want to type each folder name or its drive name so i added my batch file to right click of my mouse
    i want every time that i execute my batch in any of my folders it scan files and folders names including subfolders and make a report.text file
    then copy these files and folders from current folder to a new destination d:\bacup
    how can i do it
    i would be very glad if you write a batch script for me
    by the way i found lots of batch file but none of them was the write one
    thanks

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: copy all files and folders from current folder
    « Reply #1 on: April 01, 2012, 12:51:22 PM »
    First, an opinion
    Begin IMHO
      DOS is dead. 
      For some things it still is quick and easy,
      - but so is Duct Tape.
    End of IMHO
    Some basic DOS things your mother did not tell you about.
    This command shows ONLY directories below the current:
    Code: [Select]
    DIR /AD Same thing, but no details
    Code: [Select]
    DIR /AD /B Same thing, but get the lower levels too.
    Code: [Select]
    DIR /AD /B /S
    Remember, it starts in the current directory. start from a higher nor lower level and get different results.

    This example gets all l files of all types, full path name. But never name of just the directory itself.
    Code: [Select]
    DIR /A-D /B /S
    Now add re-direction to put it into a file.
    Code: [Select]
    DIR /A-D /B /S > MyList.txt
    You can edit MyList.txt with notepad, or your favorite text editor.
    You can quickly make it into a master batch file. You can block exceptions by putting REM at the start of a line you want to skip.

    Does this give you some ideas?

    mioo_sara

      Topic Starter


      Intermediate

      Re: copy all files and folders from current folder
      « Reply #2 on: April 01, 2012, 01:45:01 PM »
      thanks for your answer dear

      i have a batch script
      its working but not the way i want !! :P
      i dont know why  it copy  but the structures of destination folders and files  are not the same as source !
      i mean it copy lots of files out of their  folders  and some subfolders never copid !!
      those were not read only  or system  type ! ???
      have a look  at script  and see if can help? ;)
      Quote
      @echo off
      dir/s/b/ad | find/v "()"> filelist.txt
      FOR /F "skip=1 eol= tokens=* delims= usebackq" %%i IN (filelist.txt) DO xcopy/e/y/c "%%i" d:\backup

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: copy all files and folders from current folder
      « Reply #3 on: April 01, 2012, 02:54:15 PM »
      Not sure why you need a file listing to key off of. I used a drag and drop template to create this. If it's attached to the context menu, it just might work:

      Code: [Select]
      @echo off
      setlocal

      xcopy /e /c /y %1 d:\Backup

      Good luck. 8)

      Quote
      Begin IMHO
        DOS is dead.
        For some things it still is quick and easy,
        - but so is Duct Tape.
      End of IMHO

      DOS is dead? When did this happen? How tragic. Was it a beautiful service?  I wonder how my 27yo IBM-AT running PC-DOS 7 will take this news; at his age most of his friends are gone.

      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: copy all files and folders from current folder
      « Reply #4 on: April 01, 2012, 03:56:41 PM »
      Really, it is not my opinion at all.  :o

      Look at this article, from late last year. His dry sarcastic wit makes then point.
      Quote
      DOS Will Never Die!
      By Dan Mabbutt, About.com Guide   August 29, 2011
      A continutation of a popular (?) series.
      The last time I wrote a blog like this, I got some serious kickback.
      "It's already dead, Doofus! DOS hasn't been needed for Windows since Windows 3.1!"
      "Do you see DOS anywhere in Windows? Repeat after me: C-O-M-M-A-N-D P-R-O-M-P-T."
      Yeah, yeah, yeah. If it DIR's like DOS and ECHO's like DOS, then it is DOS. Writing "Command Prompt" all the time gives me carpal tunnel.
      ...

      ......
      I rest my case.

      mioo_sara

        Topic Starter


        Intermediate

        Re: copy all files and folders from current folder
        « Reply #5 on: April 01, 2012, 11:32:37 PM »
        dear Sidewinder
        thanks but your cod is not working

        Quote
        0 File(s) copied
        Press any key to continue . .
        .

        by the way i dont want to copy just files i want to copy all the files and folders including subfolders from current folder to d:\Backup

        Quote
        Not sure why you need a file listing to key off of. I used a drag and drop template to create this. If it's attached to the context menu

        its port of a bigger program my friend its not just a copy

        Salmon Trout

        • Guest
        Re: copy all files and folders from current folder
        « Reply #6 on: April 02, 2012, 12:05:04 AM »
        I rest my case.

        That guy is a fool.


        mioo_sara

          Topic Starter


          Intermediate

          Re: copy all files and folders from current folder
          « Reply #7 on: April 02, 2012, 12:55:18 AM »
          guys please just answer my  question ???  you  have all the time to fight ! ;D

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: copy all files and folders from current folder
          « Reply #8 on: April 02, 2012, 01:28:38 AM »
          Making backups is best done with a backup program.

          To make it easy to understand, I shall use some metaphors. If you skip a step, it gets very bad. so detail is important.

          A backup program is like hiring a moving company to stuff your stuff into a van.
          You stuff in smashed into a big box and sent somewhere and you have to unpack it. Ugh!

          Use the right DOS command is more like the transporter in Star Trek. You get an exact duplicate in another place

          When you wish to replicate an entire content of one folder tree to another folder, there is a method using XCOPY. The destination folder should be empty if you put nit in a batch file.

          You must understand how XCOPY works. Try XCOPY /? for help.

          You need to understand the idea of 'current folder' in DOS.

          Let's say the D: drive has a folder named 'Boston' and is the place I want to start.
          And the E: has a folder named 'Chicago' and is where I wnat to replicate all the streets and cars found in 'Boston' using a single command.
          First I got to 'Boston' and look around.
          Code: [Select]
          D:
          CD BOSTON
          DIR
          Looks good.
          Now I look at 'Chicago and make sure it is empty. If not, failure is probable.
          Code: [Select]
          E:
          CD CHICAGO
          DIR
          OK. Coast is clear.
          Now return to the source drive. Don't change anything.
          Code: [Select]
          D:At this point the default directory on E: is  'Chicago' and I and now on 'Boston' on D:
          Now I give this command at the DOS prompt.
          Code: [Select]
          XCOPY D: E: /E /H
          This post is not intended to be annoying. Using DOS commands is not very intuitive. This is the best I know how to do at explaining.  Use of metaphors makes things easier that using the technical names of things.

          If XCOPY does not work for you, please come back.

          Microsoft DOS xcopy command





          mioo_sara

            Topic Starter


            Intermediate

            Re: copy all files and folders from current folder
            « Reply #9 on: April 02, 2012, 04:16:28 AM »
             :)dear Geek-9pm
            thanks for your help  and your teaching
            but wish you  had a look at my   post number 3 :P
            you  can  see that i used xcopy command and its working now !! :( but cuz source folder is changing every day so program should find the source folder (that is my  current folder)  and copy any folder and files from there to destination folder (d:\backup)
            something else this script will  be used in  another program later

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: copy all files and folders from current folder
            « Reply #10 on: April 02, 2012, 09:27:47 AM »
            Quote
            i found lots of batch files that can copy files or folders but i need a special one
            first of all i have more than 3000 folders including subfolder in my multi hard drives so i dont want to type each folder name or its drive name so i added my batch file to right click of my mouse

            Please explain more about where you click the right mouse button. If you're in Explorer then I doubt you can select a folder and retrieve the path for your batch file (not easily anyways). VBScript has a BrowseForFolder method which could pass back a selected folder path on the console. The batch file could retrieve the value and use it in the XCOPY command. You might also use the %cd% variable but you might be surprised at the value when running from the context menu.

            Note that the VBScript solution would be interactive which you may not want in a batch file.

             8)

            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            mioo_sara

              Topic Starter


              Intermediate

              Re: copy all files and folders from current folder
              « Reply #11 on: April 02, 2012, 09:58:39 AM »
              dear Sidewinder :)
              no mater where i  right click (on a file of folder when i right click )i can see my batch
              so you guess batch is in current folder and i want to run it so it should copy whatever (folders and files) to destination folder (d:\backup)
              i hope i could explain what i'm  looking for :)
              have a look  at post #3
              if you change xcopy to move it will work like a charm but unfortunately i want to copy and not move

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: copy all files and folders from current folder
              « Reply #12 on: April 02, 2012, 11:27:55 AM »
              Quote
              no mater where i  right click (on a file of folder when i right click )i can see my batch
              so you guess batch is in current folder

              Maybe I'm just dense but where do you see a file or folder to right click on? You  mentioned you added your batch file to a right mouse click. How? I'm not understanding how clicking a folder would change the current directory. My guess is that you see you batch file as an entry on the context menu not as a member of a folder.

              The only way I see this working with a minimum of craziness, would be to navigate to the directory you want to copy and then run your batch file (use a fully qualified path) from the command prompt.

              Also you may want to pipe a "D" to the xcopy command to prevent a console prompt:

              echo D | xcopy ...

               8)




              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              mioo_sara

                Topic Starter


                Intermediate

                Re: copy all files and folders from current folder
                « Reply #13 on: April 02, 2012, 01:25:12 PM »
                Quote
                My guess is that you see you batch file as an entry on the context menu
                this is correct my friend  ;D

                i can't see batch name when i right click on folders but just on files
                but you imagine i copid my batch in current folder and run it ok?  ::)  i need to copy all the contents to destination
                i mean both folders and files that are located in the current folder
                i hope i could explain this tragic situation !!! :-X

                Sidewinder



                  Guru

                  Thanked: 139
                • Experience: Familiar
                • OS: Windows 10
                Re: copy all files and folders from current folder
                « Reply #14 on: April 02, 2012, 02:52:59 PM »
                You keep repeating yourself, but I still can't visualize what you are trying to do. Please answer my questions.

                What program is displaying this list of files and folders?

                If you select a folder, and right click the mouse, what do you expect to happen?

                How did you attach the batch file to the context menu. As far as I know, this has to be done thru the registry. Is this what you did?

                Like I mentioned, a combination of VBScript and batch code can do this, but at this point I'm not sure what you really want.

                Gotta go. The radio is playing Zeppelin's Dazed and Confused.  ;D

                The true sign of intelligence is not knowledge but imagination.

                -- Albert Einstein