Hy
I want to save my daily works from a folder named TODAY to a folder called today's date for example 28.02.2011 created on USB Memory Stick.
The big problem is that the Stick Drive letter is sometime H:, sometime K:, sometime I: >>>>> so I dont know the Stick Drive Letter...
I want to write this commands in a bat file but unfortunately I don't know the Stick drive letter...
I appreciate any help.
thank's
Save to USB memory stick
Moderator: DosItHelp
Re: Save to USB memory stick
Code: Select all
@Echo Off
setlocal EnableDelayedExpansion
Set "Source=TODAY"
Set /A Cnt=0&For /F "Tokens=2 Delims==" %%A In (
'WMIC LogicalDisk Where ^(DriveType^=2 And MediaType^=NULL^) Get Name /Value'
) Do (Set /A Cnt+=1&Set Usb!Cnt!=%%A&Echo.!Cnt!. Copy to drive %%A)
Echo.&Set /P "Number=Please, enter the number "
Set Usb%Number% >nul 2>&1&&Call xCopy /S /I /Y "%Source%" !Usb%Number%!\%date%||Echo Wrong number. Try again.
endlocal
Re: Save to USB memory stick
thank's !k the great HELP
Because MediaType for USB can be 0, 11 or sometime null , I want to use for filter deviceID<>'A:'
work nice, return>>
DeviceID
P:
but I need only second line ,and the bottom code don't work (Of course later I change the ECHO command with SET myUSBdriveIs=%i)
return
>was unexpected at this time.
what's wrong with this code
Because MediaType for USB can be 0, 11 or sometime null , I want to use for filter deviceID<>'A:'
Code: Select all
wmic logicaldisk where (drivetype=2 and deviceID^<^>'A:') get deviceID
DeviceID
P:
but I need only second line ,and the bottom code don't work (Of course later I change the ECHO command with SET myUSBdriveIs=%i)
Code: Select all
for /f "skip=1" %i IN ('wmic logicaldisk where ^(drivetype^=2 and deviceID^<^>'A:'^) get deviceID') Do (Echo %i)
>was unexpected at this time.
what's wrong with this code
Re: Save to USB memory stick
Code: Select all
for /f "skip=1" %i IN ('wmic logicaldisk where ^(drivetype^=2 and deviceID^^^<^^^>'A:'^) get deviceID') Do (Echo %i)
Re: Save to USB memory stick
unfortunately
') was unexpected at this time
') was unexpected at this time
Re: Save to USB memory stick
Hmm it works for me
Try
or
Try
Code: Select all
for /f "skip=1" %i IN ('wmic logicaldisk where ^(drivetype^=2 and deviceID^^^<^^^>^'A:^'^) get deviceID') Do (Echo %i)
Code: Select all
for /f "usebackq skip=1" %i IN (`wmic logicaldisk where ^(drivetype^=2 and deviceID^^^<^^^>'A:'^) get deviceID`) Do (Echo %i)
Re: Save to USB memory stick
with usebackq option work nice, Thank's Again