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

Author Topic: XCOPY: Asking for the destination folder  (Read 3374 times)

0 Members and 1 Guest are viewing this topic.

Neodudeman

    Topic Starter


    Rookie
    XCOPY: Asking for the destination folder
    « on: August 18, 2006, 07:19:28 PM »
    How could I have the .bat file ask for the destination folder.

    In this case I want the batch to copy a folder from my C:\ to my flash drive, but I will be using this batch on multiple computers, and the flash drive may be K:\ on one computer, but can easily change to I:\ on another. So how would I do that?

    All computers Windows XP
    « Last Edit: August 18, 2006, 08:41:49 PM by Neodudeman »

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: XCOPY: Asking for the destination folder
    « Reply #1 on: August 19, 2006, 02:09:05 PM »
    With XP you're in luck. Use the set command to get input from the user.

    Code: [Select]
    @echo off
    set /p var=Enter destination folder:
    xcopy sourcefolder %var%

    Hope this helps. 8-)

    Of course you could be really clever, write a Windows script and have the script determine the drive letter of the flash drive. But we'll leave that for another day.
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    Neodudeman

      Topic Starter


      Rookie
      Re: XCOPY: Asking for the destination folder
      « Reply #2 on: August 19, 2006, 05:51:25 PM »
      Hey, thanks! Worked fantastic! But I just have a quick question... Why do you need the @ symbol before the echo off? I did a search of the home page, and the syntax for the command, it said, was just ECHO [ON|OFF], and didn't talk about the @. Could you explain it to me?

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: XCOPY: Asking for the destination folder
      « Reply #3 on: August 19, 2006, 06:00:47 PM »
      The @ prevents the command from being echoed to the console. You can prefix any command with @, but @echo off is a catchall for every command following the echo statement or until echo is turned back on.

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

      -- Albert Einstein

      Neodudeman

        Topic Starter


        Rookie
        Re: XCOPY: Asking for the destination folder
        « Reply #4 on: August 20, 2006, 06:52:19 PM »
        Oh neat! Thanks for the explaination  ;D. But now I have another question.  :-[ Would that mean to turn the echo back on, I would need to do @echo on ?

        I'm sorry that I have to ask, but currently my computer's in Best Buy, and now I have to use linux. Ugh.  :P Though it Does present an oppurtunity to learn some python!  ;D

        Dilbert

        • Moderator


        • Egghead

        • Welcome to ComputerHope!
        • Thanked: 44
          Re: XCOPY: Asking for the destination folder
          « Reply #5 on: August 21, 2006, 01:13:38 AM »
          No. ECHO would be off, so the command "echo on" would not be shown anyway. It's only when the echo is already on that you need the @.

          Best advice: Make a small .bat file and try it. That's how I made a good 15% of my batch discoveries. :)
          "The geek shall inherit the Earth."