Copy a file from a thumb drive with a batch file.

Posted on 2011-10-13
Last Modified: 2012-05-12

I haven't written very many batch files and I stumped on what to do.  

All I want to do is copy a file to a local folder from a thumb drive.  I will label the thumb drive "Update" but it could be assigned a different letter in different machines.  What is the format to call the thumb drive by its label and not the drive letter?

I am using WinXP Pro.

Thanks for your help.
Question by:ryanbass
    LVL 43

    Accepted Solution

    I have just such as script for you here on my site:

    Can elaborate more but is fairly self explanatory I think.

    LVL 43

    Expert Comment

    by:Steve Knight
    If the batch file is run FROM the thumb drive btw you can get the path that it is run from using %~dp0 within the batch file etc.  There is a doc "find the path and name of batch file" on above site too for that :-)
    LVL 38

    Expert Comment

    by:Aaron Tomosky
    %cd% is the variable for the current folder from which the batch file is run. So like dragon said, if you can run the batch file from the flash drive and the destination folder is always the same, I'd think that would be the easiest way.
    LVL 43

    Expert Comment

    by:Steve Knight
    to make syure, %cd% doesnt always get set to the current dir.... E.g. Working directory of shortcut is different or being run from a unc network drive but %~0 will get you the path in more cases.... Nowt wrong with %cd% when it works ... Or just copy from current dir, i.e.

    Copy somefile.txt c:\otherdir

    run from thumb drive.


    Author Closing Comment

    Perfect.  Thanks a lot.
    LVL 43

    Expert Comment

    by:Steve Knight
    no problem, glad it helped.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (…
    VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now