Batch to move a column in Wmic logicaldisk... ?

May 4, 2013 at 11:13:49
Specs: Windows XP
Hi all.

I using command "wmic logicaldisk get name, volumename, filesystem" to get a list of Volume.
It print as here:

--------------------------------------------------------
FileSystem Name VolumeName
NTFS C: WinXP
NTFS D: Win8
NTFS E: Data
NTFS F: Giai Tri
CDFS G: D-com 3G
FAT32 H: LE VAN MANH
NTFS I: LEMANH
K:
--------------------------------------------------------

how do I want move column of FileSystem to last column?

--------------------------------------------------------
Name VolumeName FileSystem
C: WInXP NTFS
D: Win8 NTFS
E: Data NTFS
F: Giai Tri NTFS
G: D-com 3G CDFS
H: LE VAN MANH FAT32
I: LEMANH NTFS
K:
--------------------------------------------------------
Thanks all.


See More: Batch to move a column in Wmic logicaldisk... ?

Report •

#1
May 4, 2013 at 15:27:37
I don't know for sure if what you want to do is possible. Whenever I'm having issues with a batch script, I refer to ss64.com/index.html.

There is tons and tons of useful information on that site.

I found the link below and quickly looked it over. It does mention formatting our output, but I don't know if it's exactly what you want. Take a look and let us know.

http://ss64.com/nt/wmic.html

Law of Logical Argument: Anything is possible if you don't know what you're talking about.


Report •

#2
May 4, 2013 at 15:54:36
What I love about ss64.com is that they do a
<command> /?
from command prompt, and copy/paste the results. It's that kind of brazen plagiarism that gives me hope for the next generation.

How To Ask Questions The Smart Way


Report •

#3
May 4, 2013 at 16:01:20
Haha! Good point Razor! I've noted that as well, but for me, its nice to not have to keep bringing up different cmd windows and continuously re-typing the command I want to see! I suppose im lazy though... wish I would have thought of it first!!! ;)

Law of Logical Argument: Anything is possible if you don't know what you're talking about.


Report •

Related Solutions

#4
May 4, 2013 at 16:32:46
Depending on what you want you could pass this into a txt file and the pass it through a for statement with " " as a delimiter.

:: mike


Report •

#5
May 4, 2013 at 19:11:48
Since the output is unicode (a defect, imo), and also posesses the defect of having excess car. rets embedded, it needs extra attention for batchscript. This tries to accomodate these handicaps:
::====begin batchscript
@echo off>wmi & setlocal enabledelayedexpansion
for /f "tokens=1,2*" %%a in ('wmic logicaldisk get name^, volumename^, filesystem') do (call :xx %%a %%b %%c)
goto :eof
:xx
if "%2" neq "" (
>> wmi echo %2*%3*%1
)
::===== end batch
you will note i skipped elements that had no filesystem attached. It tended to confuse the output. Also, I used * to delimit the fields instead of space due to possibility of spaces in volumenames (of course i guess there could also be asterisks!). Choose your own delimiter and proceed from there. Vbscript would be a better option and could probably draw this same information from objects without using wmic, but I'm not currently "up to speed" on that.

Report •

#6
May 4, 2013 at 20:49:18
nbrane: Vbscript would be a better option and could probably draw this same information from objects without using wmic, but I'm not currently "up to speed" on that.
Shortest version is 3 lines:
For Each drive In GetObject("winmgmts:").InstancesOf("Win32_LogicalDisk")
  WScript.Echo drive.Name & "*" & drive.VolumeName & "*" & drive.FileSystem
Next 'drive

How To Ask Questions The Smart Way


Report •

#7
May 4, 2013 at 21:32:06
Ha ha! yah, I suspected this were the case 'ere.

Report •

#8
May 5, 2013 at 04:31:35
:: ===== script starts here ===============
::
:: swaocols.bat 2013-05-05 17:52:32.34
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

wmic logicaldisk get name, volumename, filesystem > out

for /f "tokens=1-3 delims= " %%a in ('type out') do (
if "%%b"=="" (
echo.%%a
) else (
echo.%%b %%c %%a
)
)>> NEWFILE
del out
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

#9
May 5, 2013 at 11:42:23
thanks all, has helping.

Report •

Ask Question