M0XIE Posted September 4, 2007 Share Posted September 4, 2007 Say I want to put my Pic Rip on a flash drive and have it dump all images there instead of uploading it. How would I get back to the flash drive to copy files there. I couldn't put just a,b,d,e,f,g,etc Because the drive letter will always change depending on whats already plugged into the computer. is there some set command I can use or something like %drive% Quote Link to comment Share on other sites More sharing options...
SomeoneE1se Posted September 4, 2007 Share Posted September 4, 2007 Say I want to put my Pic Rip on a flash drive and have it dump all images there instead of uploading it. How would I get back to the flash drive to copy files there. I couldn't put just a,b,d,e,f,g,etc Because the drive letter will always change depending on whats already plugged into the computer. is there some set command I can use or something like %drive%ifexist c:/copyFilesHere.txt set %drive% =c: or something like that the usb hacks have something you can copy Quote Link to comment Share on other sites More sharing options...
operat0r_001 Posted September 4, 2007 Share Posted September 4, 2007 careful http://consumerist.com/consumer/leaks/best...tuff-294012.php Quote Link to comment Share on other sites More sharing options...
GonZor Posted September 4, 2007 Share Posted September 4, 2007 assuming the working directory will be on the drive letter you wish to write to you could simply go: %cd:~0,2% If the working directory is on the f drive that code will expand to F: Quote Link to comment Share on other sites More sharing options...
M0XIE Posted September 4, 2007 Author Share Posted September 4, 2007 Gonzor, thats seems to be what I am looking for. But my brain just isn't clicking right now and I can't think how I would use that. Can you give me a brief bit of code. Like You plug in and your flash drive is j:/ Your batch is in the root of j:/ You execute it The code in the bat would be? @echo off cd c: copy blank.txt %cd:~0,2% ??? Quote Link to comment Share on other sites More sharing options...
VaKo Posted September 4, 2007 Share Posted September 4, 2007 I had to do something similar, what I ended up doing was making the batch file look for a signature file on all the possible CD drives using IF EXIST and then if it found the file, use GOTO to run a command relating to that directory. IF EXIST d:loader.bat GOTO D IF EXIST e:loader.bat GOTO E IF EXIST f:loader.bat GOTO F IF EXIST g:loader.bat GOTO G IF EXIST h:loader.bat GOTO H :D copy d:picclp32.ocx C:Windowssystem32 GOTO NET :E copy e:picclp32.ocx C:Windowssystem32 GOTO NET :F copy f:picclp32.ocx C:Windowssystem32 GOTO NET :G copy g:picclp32.ocx C:Windowssystem32 GOTO NET :H copy h:picclp32.ocx C:Windowssystem32 GOTO NET :NET (code that registered the ocx file on vista and set the LAN connection to dhcp) Ugly as hell I know, but due to the way you have to elevate the privillages your running the batchfile with for certain commands I was forced to run this particular batchfile with its current path set to %SYSTEMROOT%. This isn't something you will need to do so for your needs you would just need to add something similar looking for a file your know will only exist on your flashdrive, then use that path for your copy command. Again, there are more eloquent ways of doing this but this should help you get there. Quote Link to comment Share on other sites More sharing options...
M0XIE Posted September 4, 2007 Author Share Posted September 4, 2007 I might do that VaKo. I am still looking for a cleaner way. I am thinking, but haven't tried. @echo off ::Set Flash drive set flash=%systemdrive% ::Goto C: c: ::Then when I go to transfer I use copy blank.txt %flash%blank.txt I am still waiting for gonzor or someone else to reply about how to use %cd:~1,2% Edit I just brought up MSDOS and tried this: set flash=%systemdrive% echo %flash% It replied c: Now I am hoping that if I run that in the batch before I switch over to the c: drive %flash% will remain the flash drive. I don't have a flash drive with me, otherwise I would try right now. But if someone could let me know if this works. Actually here is a batch: @echo off set flash=%systemdrive% echo The flash drive is %systemdrive% c: echo The hard drive is %systemdrive% echo The flash drive is %flash% echo If the first and third line are the same, echo but different than the second line, echo this worked. pause Just put that to your flash drive then run it. Let me know please. Quote Link to comment Share on other sites More sharing options...
GonZor Posted September 5, 2007 Share Posted September 5, 2007 First of all no matter what location you are at, %systemdrive% will always be the drive windows is located on. To explain what I was on about with %cd:~0,2%, the variable cd expands to the current working directory and the ":~0,2" following manipulates the string to the first two characters, therefore if you were to use your example: @echo off cd c: copy blank.txt %cd:~0,2% This would try and copy to the c: drive because that is the current working directory. If you were to change it to this: ::Set variable to flash drive letter SET flash=%cd:~0,2% ::Change to c: CD /d c: ::Copy files COPY secretstuff.txt %flash%secretstuff.txt /y I hope that explains in more detail what I am try to say. Quote Link to comment Share on other sites More sharing options...
M0XIE Posted September 5, 2007 Author Share Posted September 5, 2007 Thank you gonzor. I understand fully. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.