Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2011-10-13
Medium Priority
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
  • 4
LVL 43

Accepted Solution

Steve Knight earned 2000 total points
ID: 36962883
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
ID: 36962892
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 39

Expert Comment

by:Aaron Tomosky
ID: 36962966
%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.
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

LVL 43

Expert Comment

by:Steve Knight
ID: 36963117
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

ID: 36964537
Perfect.  Thanks a lot.
LVL 43

Expert Comment

by:Steve Knight
ID: 36964915
no problem, glad it helped.


Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

580 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