Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file with 12 columns separated by ?

I need to export column number 12 (NetBIOS Name) and append the whole row to a CSV file. Skip the first line that is the column description.

The first 4 lines af the CSV file expored from a SCCM Query:

Name    SMS Assigned Sites  IP Addresses    IP Subnets  Operating System Name and Version   Resource Domain Or Workgroup    Last Logon User Domain  Last Logon User Name    SMS Unique Identifier   Resource ID Resource Type   Netbios Name    
F101-03123D "SIC"   "172.18.1.101"  "172.18.1.0"    Microsoft Windows NT Workstation 5.1    SI  SI  aalmo06 GUID:00003D0D-A754-47ED-B2EA-D29D1C4A4124   3509    System  A202-E1210A 
F112-02478D "SIC"   "169.254.222.155"; "172.18.2.21"    "169.254.0.0"; "172.18.2.0" Microsoft Windows NT Workstation 5.1    SI  SI  aafebep GUID:A4768DE7-E3CA-42B3-90A4-3502B2F04364   3510    System  A234-A1720000B
B567-03565D "SIC"   "172.21.212.6"  "172.21.212.0"  Microsoft Windows NT Workstation 5.1    SI  SI  aabibru GUID:F81E25B7-0074-457A-9E98-1A611208D28B   5438    System  C856-153AE22    

The result/output CSV file:

A202-E1210A
A234-A1720000B
C856-153AE22
etc...

I have something like:

FOR /F "tokens=12 delims= skip=1 " %%G IN (allsystems.csv) DO @echo %%G

But what delimiters should I use here?

share|improve this question

2 Answers 2

If I understand correctly, the problem is that the file uses TAB as the delimiter. The Windows command prompt uses TAB for autocompletion, which means it cannot normally be entered as a regular character. However, you can switch that behaviour off with the following command:

cmd /f:off

Start the command prompt with that, rather than just cmd, and you can now use the Tab key to enter the character.

Alternatively, put your script into a batch file. Any text editor will allow you to enter the TAB character and the command prompt will have no problem interpreting it as such when you execute the batch file.

share|improve this answer
    
Thanks it works, here is the line: FOR /F "tokens=12 skip=1 delims= " %%G IN (allsystems.csv) DO @echo %%G >>netbios.txt –  roundup Aug 26 '12 at 17:54
    
!!! unfortunately there is still a problem, it will not get all (NetBIOS Name) in the output ??? –  roundup Aug 26 '12 at 18:06
    
Do those lines still use TAB as the delimiter? Is the NetBIOS name in the 12th field? Maybe you can edit your question and post those lines for which that command fails? –  Indrek Aug 26 '12 at 18:25

Call CSVfix from your batch file, designed for exactly this type of task.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.