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

x
?
Solved

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

Posted on 2011-10-13
6
Medium Priority
?
245 Views
Last Modified: 2012-05-12
Hello,

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.
0
Comment
Question by:ryanbass
  • 4
6 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 36962883
I have just such as script for you here on my site:

http://scripts.dragon-it.co.uk/links/batch-find-drive-by-name

Can elaborate more but is fairly self explanatory I think.

Steve
0
 
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 :-)
0
 
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.
0
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.

Steve
0
 

Author Closing Comment

by:ryanbass
ID: 36964537
Perfect.  Thanks a lot.
0
 
LVL 43

Expert Comment

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

Steve
0

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