Solved Batch File to take list and append

December 1, 2012 at 16:00:02
Specs: Windows 7
I have a word lists like this:
snooze
soar
spurt
stagger
stitch
strangle
strip


I want to use a batch file that will make the list above look like this:
"snooze", "soar", "spurt", "stagger", "stitch", "strangle"

I have about 20 lists like this with about 200 words in each one


See More: Batch File to take list and append

Report •


#1
December 1, 2012 at 17:51:08
✔ Best Answer
this might do for each file, but I don't know how to qualify the 20 files to submit each to this procedure:
::====== begin batchscript
@echo off & setlocal
set x=
::credit goes to Razor for this cool technique: "call set". Never saw that before!
for /f "tokens=*" %%a in (list1) do call set x=%%x%%,"%%a"
>list1.out echo %x~1%
::====== end batch
You could call this as a sub, or nest it into a loop, based on a list of filenames to be processed.

Report •

#2
December 1, 2012 at 17:57:07
nbrane: credit goes to Razor for this cool technique: "call set"
I picked it up from Judago.

How To Ask Questions The Smart Way


Report •

#3
December 1, 2012 at 18:05:51
He's also top-notch!
I never would have guessed that that would have a snowball's chance of working...

Report •

Related Solutions

#4
December 1, 2012 at 19:09:20
@echo off & setlocal
set x=
for /f "tokens=*" %%a in (ExpressiveVerbs.txt) do call set x=%%x%%,"%%a"
>list1.out echo %x~1%

tried it like this but it gives a text file that says:

ECHO is off.


Report •

#5
December 1, 2012 at 19:39:56
My apologies, lost the colon in trans:
>list1.out echo %x~1%
is wrong, should have colon, like:
>list1.out echo %x:~1%
Please let me know if that fixes or not. if not, I will work to fix it.

Report •

#6
December 1, 2012 at 19:50:54
Yes it does work like this! thank you for your support

Report •

#7
December 1, 2012 at 20:15:18
Seems to be limited to doing around 900 words per list, what do you consider would increase the capacity?

Note: it says The input line is too long.


Report •

#8
December 1, 2012 at 20:27:40
Maybe vbscript. It would be like this:
'===== begin vbscript
set fso=createobject("scripting.filesystemobject")
a=fso.opentextfile("list1",1).readall
r=""""+","+""""
a=""""+replace(a,vbcrlf,r)
if right(a,3)=r then a=left(a,len(a)-2)
fso.createtextfile("list1.out").write(a)
'===== end vbscript

There are probably other better ways (poss. even batch-based), but this might work for now.


Report •

#9
December 1, 2012 at 21:53:50
that vbs worked very well handled a list of 22110 words;

Report •


Ask Question