Jani
Jani

Reputation: 47

Windows cmd (batch) for loop

I'm having some problems with my for loop. This is what I got now:

@echo off
set installPrograms=CCleaner,Adobe Reader,Cute PDF Writer
for %%a in ("%installPrograms:,=" "%") do echo %%a
pause >nul

This outputs:

"CCleaner"
"Adobe Reader"
"Cute PDF Writer"

What I want this to output is:

CCleaner
Adobe Reader
Cute PDF Writer

So I'd like it to output those programs without the " " marks. Seems the spaces in the program names is causing problems if I change the code to something like:

 for %%a in (%installPrograms:,= %) do echo %%a

 Output:
 CCleaner
 Adobe
 Reader
 Cute
 PDF
 Writer

How can I make this work? Thanks.

Upvotes: 0

Views: 95

Answers (1)

Stephan
Stephan

Reputation: 56165

just replace echo %%a with echo %%~a.

The Tilde (~) removes any surrounding quotes (if there are any).

Described in for /?

Upvotes: 2

Related Questions