• Need help with batch file [RESOLVED]

    Home » Forums » AskWoody support » Backup » Backup – other » Need help with batch file [RESOLVED]

    Author
    Topic
    #2448270

    I use a batch file to copy several folders containing data files to a flash drive once a week. The problem is I have to edit the file almost every time I use it because the flash drive letter may have changed from the last time I ran the program. I would like to have the program ask for the correct drive letter and then carry on copying folders to this drive. Thanks for your help.

    • This topic was modified 1 month, 1 week ago by Susan Bradley.
    • This topic was modified 1 month, 1 week ago by RetiredGeek. Reason: Marked as resolved
    Viewing 8 reply threads
    Author
    Replies
    • #2448280

      If you go into Computer Management, you can assign a drive letter to that drive. I suggest choosing a letter near the bottom of the alphabet, since it would be unlikely to ever be used otherwise. My flash drive, for instance, is Drive Q every time I plug it in (daily). If for whatever reason that doesn’t work for you, post back and we’ll try Plan B.

    • #2448287

      Thanks for that. I’ll give it a try and see what happens. Any reason not to assign B to the flash drive? It’s been a long time since I’ve had a floppy drive with that letter and it’s not likely to be used by anything else.

    • #2448343
    • #2448383

      I use a free program called USBDLM (USB Drive Letter Management). It allows you to assign drive letters automatically based on the Volume Serial number of a device. THe VolSer No only changes if you either Reformat the drive or use a program to change it.

      I use it to control my 6 different bare hard drives that I use for taking system images with Macrium Reflect. I have it set so any one of the 6 will automatically mount as I: (for Image) whether I mount on any one of my machines with a USB drive dock. Works like a charm.

      HTH

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #2448393

      Assigning a drive letter to any external drives works very well. Every drive you see in this screen shot shows up with the same drive letter and name every time.

      All-my-drives

    • #2448424

      for %%x in (g f e d) do if exist %%x:\ident.dat set USBdrive=%%x

      ident.dat can be any file you expect to find on your USB.

      cheers, Paul

    • #2448431

      If you can run the BATch file from the USB flash drive itself, then you can determine dynamically the drive letter plus colon (e.g. F:) from a variable, as follows:

      Code:
      :: determine the drive letter (plus colon) of the
      :: USB drive whereon this BATch file is located
      set usb=%~d0
      echo %usb%
      pause

       

      BATcher

      Plethora means a lot to me.

    • #2448906

      If you want your batch file to prompt for the drive letter like you asked, you can do it this way.

      set /p dl=”Enter drive letter: ”

      You’d then replace the drive letter in your commands with the variable name %dl% – e.g.

      robocopy c:\source %dl%:\target /e

      The solutions above might be better though.

    • #2448975

      Thanks to all for your suggestions. I found BATcher’s works perfectly for what I’m trying to do, and have implemented it. Thanks again.

    Viewing 8 reply threads
    Reply To: Need help with batch file [RESOLVED]

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: