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 26912 times)

0 Members and 2 Guests are viewing this topic.

Salmon Trout

  • Guest
Re: copy all files and folders from current folder
« Reply #15 on: April 02, 2012, 03:43:30 PM »
If you select a folder, and right click the mouse, what do you expect to happen?

A context menu which includes Send To should appear, shouldn't it?



soybean



    Genius
  • The first soybean ever to learn the computer.
  • Thanked: 469
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 10
Re: copy all files and folders from current folder
« Reply #16 on: April 02, 2012, 06:01:36 PM »
... 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) ...
Why not get a freeware file synchronization/backup program such as Allway Sync - there are others but this is one I've used - and use it to achieve your objective?  Seems to me this would be easier solution than trying to resort to some DOS technique.

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 #17 on: April 02, 2012, 06:26:05 PM »
Why not get a freeware file synchronization/backup program such as Allway Sync - there are others but this is one I've used - and use it to achieve your objective?  Seems to me this would be easier solution than trying to resort to some DOS technique.
I agree. Some Sync utilities can be invoked with a template to automate a task. That might be called 'batch' programming, but it is not just plain  DOS. Many programs  run from a command line and run a script.

Example:some programs are written in Excel and use VBA. Such business class programs  backup and archive files that have been imported.  Such are often paid only programs. Some are found on download.com and have free trial.

But not knowing the intent of the OP, it is hard to know if giving bits and pieces of DOS code if he does not understand how to integrate the parts. And it not clear if he wants to invoke the DoS batch code from the GUI or the command line.

IMHO the OP needs to read some tutorials on VBscript and Cscript.
Using the command-based script host (CScript.exe)
« Last Edit: April 02, 2012, 06:36:50 PM by Geek-9pm »

mioo_sara

    Topic Starter


    Intermediate

    Re: copy all files and folders from current folder
    « Reply #18 on: April 02, 2012, 10:21:18 PM »
    Quote
    As far as I know, this has to be done thru the registry. Is this what you did?

    yes i add it thru registry

    Quote
    But not knowing the intent of the OP, it is hard to know if giving bits and pieces of DOS code if he does not understand how to integrate the parts. And it not clear if he wants to invoke the DoS batch code from the GUI or the command line.
    its part of my flash project .unfortunately  flash is so week  for working with windows so i should do the rest with batch programing !
    i used lots of batches and 80% of the job has done so  i  prefer to do the rest in  this way

    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 #19 on: April 03, 2012, 01:16:38 AM »
    Quote
    its part of my flash project .unfortunately  flash is so week  for working with windows so i should do the rest with batch programing !
    i used lots of batches and 80% of the job has done so  i  prefer to do the rest in  this way

    Now I am totally confused. You want to flash the  BIOS?
    No, you want to write a system utility using Adobe Flash. Huh?

    The natural choice for a Flash app is to extend it with Java. But C# would also work.  Even current versions of Visual Basic control FLASH thing.

    I have never hears of DOS batch used as a supplement, extension or replacement for Flash. But there is a lot I don't know.  :-X

    Are you writing a Windows app or a browser app?  Browser apps often use JavaScript, vb-scrip, ActiveX  or even Java at the client side.

    The DOS batch stuff is essentially twenty years old. With a few improvements in recent years. IMHO it is not well suited for browser apps. It is suited for doing backups and archives and removing dead files. Not so good for doing anything visual.

    Only 80% of your code works? Did you model the code? You need to get up to 99 % of your code working before working on kinks.
    Have you verified the logic and sequence of your code?

    A practice of professional programmers is to write a large part of the code in the best programming tool that they can use. Then fill in the tough spots with things imported from other software tools.

    I am unable to visualize this with FLASH and DOS batch.
    Sorry I can not help you with your quest. But keep at it and eventually you will find a solution.  It is not really impossible.

    Have you ever read books on structured programming? Or books about program design and  incremental refinement ?
    Books on structured programming with  C#

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: copy all files and folders from current folder
    « Reply #20 on: April 03, 2012, 05:52:15 AM »
    A context menu which includes Send To should appear, shouldn't it?
    I agree.  Putting it into the SendTo menu which doesn't require a registry edit works perfectly.  I have done that with a few of my batch files over the years.

    Another option would be to just drag the source folder onto the batch file which would take it as input in the variable %1.

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: copy all files and folders from current folder
    « Reply #21 on: April 03, 2012, 05:57:15 AM »
    OK. Last try. This goes back to the original question as I understand it or at least how I think I understand it. First up is a VBScript to allow the user the select a folder for the XCOPY operation:

    Code: [Select]
    Const RETURN_ONLY_FOLDERS = &H0001
    Const WINDOW_HANDLE = 0
    Const MY_COMPUTER = 17

    Set objShell  = CreateObject( "Shell.Application" )
    Set objFolder = objShell.BrowseForFolder( WINDOW-HANDLE, "Select Folder", RETURN_ONLY_FOLDERS, MY_COMPUTER )

    'Check For Cancel Button; Nothing Returned
    '
    If TypeName(objFolder) <> "Nothing" Then
      WScript.Echo objFolder.Items.Item.Path
    End If   

    Save the script in any folder with any name and a VBS extension.

    Next up is the batch code. Replace the for statement in your existing batch file with the code below:

    Code: [Select]
    set target=D:\Backup
    for /f "tokens=* delims=" %%i in ('cscript //nologo drive:\path\scriptname.vbs') do (
      if .%%i NEQ . (echo D | xcopy "%%i" %target% /e /c /y > d:\filelist.txt
      ) else ( goto :eof )


    Change drive:\path\scriptname.vbs to point to where you saved the VBS script.

    The user will be presented with a dialog allowing selection of any folder on the system. Only folders are shown to reduce clutter. Use the left mouse button to highlight the folder name and press OK. The folder path will be returned to the batch file for use by the XCOPY operation. If you CANCEL the folder dialog, the entire batch file will terminate. A file will also be created with a listing of what was copied. (filelist.txt)

    Feel free to tweak the code as needed.

    If you find this useful, then great. If not, well then not so great.

    Exit stage left.  8)
    « Last Edit: April 03, 2012, 06:51:17 AM by Sidewinder »
    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 #22 on: April 04, 2012, 02:06:32 AM »
      dear Geek-9pm

      Quote
      you want to write a system utility using Adobe Flash. Huh

      yes . but i don't use latest version(adobe cs4 or 5) i'm using adobe flash 8
      its rather old but unfortunately  i should use it .in  cs4 or 5 adobe added adobe air so you can  work directly  with the outside world throu java vb or lots of other scripting languages

      Quote
      I am unable to visualize this with FLASH and DOS batch

      adobe flash 8  has not allowed any  command that even think  about executing anything(except media ) even  opening a window in  windows explorer is a big problem ! and you  should do  lots of scripting tricks!! :-X

      Quote
      Only 80% of your code works?
      no  i never said that !!  :o what i mean was my project has reached to  80% and its near to  end

      by  the way  thanks for the link ;)

      mioo_sara

        Topic Starter


        Intermediate

        Re: copy all files and folders from current folder
        « Reply #23 on: April 04, 2012, 02:08:10 AM »
        dear Squashman

        please read post below i  think my  bad English  is the problem ! :-\

        mioo_sara

          Topic Starter


          Intermediate

          Re: copy all files and folders from current folder
          « Reply #24 on: April 04, 2012, 02:10:48 AM »
          dear Sidewinder
          thanks for the time and script that you  wrote for me ;)
          its working very  nice but wish  it could act automatically it needs final  user to  specify  the source folder . cant it be done by  the program itself?
          please read my  last post i pot another script and another explain i  think  cuz of my  bad English  i explain the situation awful!! ::)

          mioo_sara

            Topic Starter


            Intermediate

            Re: copy all files and folders from current folder
            « Reply #25 on: April 04, 2012, 02:24:44 AM »
            ok  guys i'm  back again ! ;D
            sometimes knowing a language is not enough and you should know how to ask !
            Albert Einstein !!! ;D ;D ;D

            first of all  sorry  for my  bad English  its my  teacher's  fault !
            i think i explained a simple question  in a very hard or bad way and i made the situation very hard and so  i did not got what i wanted at the first place
            now forget about right click or any stupid idea that i said at the post #1( wish i could edit it)
            now i try to  explain my  question in  a easy  to  understand way


            lets imagine  we have a folder (named johns) and we want to copy all the files and folders(including sub folders)from johns to  d:\backup
            that's all  that's what i want !!   :P  so we copy  a batch file to johns  folder and run  it.. now batch should start the copying process .is it that hard for even old fashion Dos base batch file to do? ??? ???
            now the problem  is that if i could put source folder name (johns) in batch script problem  could be solved but cuz final program will use these batches and source folder name will  be changed in a frequently  time so i prefer that batch  do this job  for me
            i mean  batch  Dir from  the current folder and copy  any including object to  the destination
            below you  can  see a simple batch that do this but instead of coping it moves the objects(i don't like this)

            Quote
            @echo off
            cd
            dir/s/b > filelist.txt
            for /f "delims=" %%F in (filelist.txt) do move "%%F" "D:\backup"

            any idea ?
            « Last Edit: April 04, 2012, 02:48:55 AM by mioo_sara »

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: copy all files and folders from current folder
            « Reply #26 on: April 04, 2012, 03:23:28 AM »
            If it is the current directory you wish to copy, you can specify the current directory using a period (.):

            For example, let us go with your example; let's say we have a folder Johns on C: drive; Let's say we are writing the batch file to run from within that folder (again, following your example scenario).

            if we want to copy all files and folders from the current directory, we can use xcopy and the period

            Code: [Select]
            xcopy . D:\backup /s /i

            There is something of a complication: this doesn't necessarily refer to the folder the batch file is in. If  you want to always refer to the folder that the batch is in (as opposed to the current directory of the command prompt session running the batch file) you can use this instead:

            Code: [Select]
            xcopy %~dp0 D:\backup /s /i






            I was trying to dereference Null Pointers before it was cool.

            mioo_sara

              Topic Starter


              Intermediate

              Re: copy all files and folders from current folder
              « Reply #27 on: April 04, 2012, 02:03:11 PM »
              my my my dear BC_Programmer :) thank you  very much  it worked like a charm :)
              that was a simple but breath taking question ! you really  help  me thank again
              i was really  becoming disappointed and thought its simple but its not possible with dos !
              i pressed thanks button  and if there was 200 more buttons there i would have pressed them  for you
              =================

              and other guys
              Geek-9pm ---Sidewinder---Squashman----Salmon Trout
              thank you  all too you  tried to  teach  me a lot :)


              mioo_sara

                Topic Starter


                Intermediate

                Re: copy all files and folders from current folder
                « Reply #28 on: April 08, 2012, 12:51:15 PM »
                    i have a little problem  i forgot to  ask  how should this batch  file create a folder in  destination  and rename it to  current folder's name before copying files and folders from current directory  to  it
                    in  another language
                    1-first create a folder in destination  d:\backup\ and rename it to  current folder's name= example johns(where my  files and folders located now)
                    2- now copy  files and folders from current directory(johns)  fo  d:\backup\ new destination  folder (example=johns)
                    thanks :)


                mioo_sara

                  Topic Starter


                  Intermediate

                  Re: copy all files and folders from current folder
                  « Reply #29 on: April 10, 2012, 01:54:09 AM »
                  thanks  its done above post has been  solved thanks dear friends ;)