How to fetch a particular column using batch scripting?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dipanchandracsc
Posts: 2
Joined: 21 May 2012 04:00

How to fetch a particular column using batch scripting?

#1 Post by dipanchandracsc » 21 May 2012 19:23

Hi all,

Hope you are doing great !!!

Here is a novice query : :) I have the following text with me :

Code: Select all

  
  Volume 0     E                       CD-ROM          0 B  Healthy
  Volume 1     D                NTFS   Partition     80 GB  Healthy
  Volume 2     C                NTFS   Partition     25 GB  Healthy    System


off which, my requirement is to fetch the column consisting
[list=]
E
D
C[/list]

Please help me out with it :)

Thanks !!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to fetch a particular column using batch scripting?

#2 Post by foxidrive » 21 May 2012 21:39

Try this:

Code: Select all

@echo off
for /f "tokens=3" %%a in ('type "file.txt"') do echo %%a

dipanchandracsc
Posts: 2
Joined: 21 May 2012 04:00

Re: How to fetch a particular column using batch scripting?

#3 Post by dipanchandracsc » 21 May 2012 23:31

Thanks foxidrive 8)

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: How to fetch a particular column using batch scripting?

#4 Post by Squashman » 22 May 2012 05:57

Assuming you got that output from DISKPART you could just have a diskpart script and execute it like this.

Code: Select all

for /f "skip=8 tokens=3" %%G in ('diskpart /s dpscript.txt') do echo %%G

Post Reply