1.

Solve : for somthing = %%a?

Answer»

Hi All,
I have write batch to dir my folders in every DRIVE at pc. so far I write it in this way

@echo
cd\
c:
pause

dir c:\
@echo
pause
d:\
dir d:\
pause
e:\
dir e:\

I would like to find out any other way to dir all drives without naming this drives.

This might help you out.

Code: [Select]@echo off
for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
dir %%i:
)

for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "dvd-rom"') do (
dir %%i:
)

for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "removeable"') do (
dir %%i:
)

For network drives use net use. You can use the same technique to filter the output.

Good luck.I think you spelled removable wrong. That may be an issue if the op tries to dir a flashdrive. Au contraire. I can't make this stuff up but Microsoft can.

Quote
C:\Temp>echo list volume | diskpart

Microsoft DiskPart version 5.1.3565

Copyright (C) 1999-2003 Microsoft Corporation.
On computer: LAPTOP

DISKPART>
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 H DVD-ROM 0 B
Volume 1 C xpSystem NTFS Partition 17 GB Healthy System
Volume 2 D xpData NTFS Partition 2000 MB Healthy
Volume 3 E xpWare NTFS Partition 9 GB Healthy
Volume 4 F xpServices NTFS Partition 2000 MB Healthy
Volume 5 G xpMedia NTFS Partition 6001 MB Healthy
Volume 6 I KINGSTON FAT32 Removeable 954 MB

DISKPART>
C:\Temp>
Quote
I think you spelled removable wrong

Quote
I can't make this stuff up but Microsoft can.

This has been discussed in various places. The spelling seems to be a USA vs rest-of-the-world thing, rather like color/colour, center/centre, meter/metre etc; UK English dictionaries tend to give the spelling without a second 'e' but "removeable" is a fairly widespread variant spelling in the US. Merriam-Webster says:

3 : to be capable of being removed

— re·mov·abil·i·ty \-ˌmü-və-ˈbi-lə-tē\ noun

— re·mov·able also re·move·able \ri-ˈmü-və-bəl\ adjective

— re·mov·able·ness \-ˈmü-və-bəl-nəs\ noun

— re·mov·ably \-blē\ adverb

— re·mov·er noun Quote
The spelling seems to be a USA vs rest-of-the-world thing, rather like color/colour, center/centre, meter/metre etc

Could be, but the MS Word 2002 (XP) spell checker shows the correct spelling as removable. All in all it makes no difference. When dealing with data, you've got to handle it as it is.Quote from: Sidewinder on October 21, 2009, 04:50:38 PM
Au contraire. I can't make this stuff up but Microsoft can.

Hmm...is that a MS world-wide thing? I haven't noticed that and my regional settings are set to canada (I think). Quote from: Sidewinder on October 21, 2009, 12:35:53 PM
This might help you out.

Code: [Select]@echo off
for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
dir %%i:
)

for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "dvd-rom"') do (
dir %%i:
)

for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "removeable"') do (
dir %%i:
)

For network drives use net use. You can use the same technique to filter the output.

Good luck.

thank you for your help .. and
I tried this but I get an error ? that :Application data "dir" is not recognized as an internal or external command, operable PROGRAM or batch command file.

Not sure what :Application data indicates. The code was designed to run from the prompt in a cmd window. Need more details. A copy and paste of the error message and what went before it would be most helpful.

Quote from: Sidewinder on October 26, 2009, 07:17:37 AM
Not sure what :Application data indicates. The code was designed to run from the prompt in a cmd window. Need more details. A copy and paste of the error message and what went before it would be most helpful.



here in below a copied of error massage



Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\ammmmm>@echo off
for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"')
do (
%%i was unexpected at this time.
"Application Data"dir %%i:
'"Application Data"dir' is not recognized as an internal or external command,
operable program or batch file.
"Application Data")
'"Application Data")' is not recognized as an internal or external command,
operable program or batch file.

for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "dvd-rom"') d
o (
%%i was unexpected at this time.
"Application Data"dir %%i:
'"Application Data"dir' is not recognized as an internal or external command,
operable program or batch file.
"Application Data")
'"Application Data")' is not recognized as an internal or external command,
operable program or batch file.

for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "removeable"'
) do (
%%i was unexpected at this time.
"Application Data"dir %%i:
'"Application Data"dir' is not recognized as an internal or external command,
operable program or batch file.
"Application Data")
'"Application Data")' is not recognized as an internal or external command,
operable program or batch file.


thank youApplication data is a directory immediately below the username directory in documents and settings. I haven't a clue how that error message was generated.

From what I can tell, you are typing this in at the command prompt, (I read you wanted a batch file) in which case you should only use single % signs and the do instruction with at least the open paren should be on the same line as the if, otherwise the interpreter has no clue that the line is incomplete and requires more.

When typing at the command line:
Code: [Select]d:\wfc\testlib>for /f "tokens=3" %i in ('echo list volume ^| diskpart ^| find /i
"partition"') do (
More?

NOTE: It appears the for intruction is two lines long, however the interpreter sees the line as one logical line that requires completion.

I suggest you copy/paste the code I posted earlier into an editor, create a batch file, and then run run the batch file.



Discussion

No Comment Found