Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
atamo
- Posts: 15
- Joined: 17 May 2010 09:14
#1
Post
by atamo » 23 Feb 2011 03:08
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
-
!k
- Expert
- Posts: 378
- Joined: 17 Oct 2009 08:30
- Location: Russia
#2
Post
by !k » 23 Feb 2011 08:57
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
-
atamo
- Posts: 15
- Joined: 17 May 2010 09:14
#3
Post
by atamo » 15 Mar 2011 12:44
thank's !k the great HELPBecause 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
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)
Code: Select all
for /f "skip=1" %i IN ('wmic logicaldisk where ^(drivetype^=2 and deviceID^<^>'A:'^) get deviceID') Do (Echo %i)
return
>was unexpected at this time.
what's wrong with this code

-
!k
- Expert
- Posts: 378
- Joined: 17 Oct 2009 08:30
- Location: Russia
#4
Post
by !k » 15 Mar 2011 13:17
Code: Select all
for /f "skip=1" %i IN ('wmic logicaldisk where ^(drivetype^=2 and deviceID^^^<^^^>'A:'^) get deviceID') Do (Echo %i)
-
atamo
- Posts: 15
- Joined: 17 May 2010 09:14
#5
Post
by atamo » 15 Mar 2011 13:48
unfortunately
') was unexpected at this time

-
!k
- Expert
- Posts: 378
- Joined: 17 Oct 2009 08:30
- Location: Russia
#6
Post
by !k » 15 Mar 2011 14:52
Hmm

it works for me
Try
Code: Select all
for /f "skip=1" %i IN ('wmic logicaldisk where ^(drivetype^=2 and deviceID^^^<^^^>^'A:^'^) get deviceID') Do (Echo %i)
or
Code: Select all
for /f "usebackq skip=1" %i IN (`wmic logicaldisk where ^(drivetype^=2 and deviceID^^^<^^^>'A:'^) get deviceID`) Do (Echo %i)
-
atamo
- Posts: 15
- Joined: 17 May 2010 09:14
#7
Post
by atamo » 16 Mar 2011 07:50
with
usebackq option work nice, Thank's Again
