How to read lines in a text file with spaces?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vishnuj
Posts: 4
Joined: 18 Dec 2013 04:06

How to read lines in a text file with spaces?

#1 Post by vishnuj » 18 Dec 2013 04:09

I have a file called file.txt in which it contains few lines as
vishnu
ram
gopal
suresh
chandra sekar
prem kumar
nandhu

I have written a batch script to read each line and to create a folder and assign the lines as name to that folder.

FOR /f "tokens=* delims=" %a in (file.txt) DO @md %a

but, the folder created as vishnu, ram, gopal, suresh, chandra, sekar, prem, kumar, nandhu

Here the chandra and sekar are seperated as two folders, but i want the chandra sekar as a single folder name, how to acheive this?

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

Re: How to read lines in a text file with spaces?

#2 Post by foxidrive » 18 Dec 2013 04:13

Use Quotes. :)

Code: Select all

@md "%a"



This bloke is not likely to return here.
http://stackoverflow.com/questions/2065 ... tch-script

vishnuj
Posts: 4
Joined: 18 Dec 2013 04:06

Re: How to read lines in a text file with spaces?

#3 Post by vishnuj » 18 Dec 2013 04:20

Thank you very much.. This works.... :)

Post Reply