For Loop Ignore Wildcards

Microsoft Windows xp professional w/serv...
February 23, 2011 at 06:05:09
Specs: Windows XP
Hi All,

I have a variable that its value is read from a configuration file and contains some file patterns, comma separate, like: *.txt,*.sus

I could not find a way to loop over the values ignoring the wildcard, I mean, I need to download those file patterns from a remote server and I need to loop over them to do this.

Please, check the code below:
###################################################################
setLocal EnableDelayedExpansion
SET FILE_EXTENTIONS=*.txt,*.sus

FOR /F %%P IN ("!FILE_EXTENTIONS!") DO (
SET FILEEXTENTION=%%P
ECHO "FILEEXTENTION: [!FILEEXTENTION!]"
)
###################################################################

The way above, it prints the two file extentions without looping over them. It prints:
###################################################################
"FILEEXTENTION: [*.txt,*.sus]"
###################################################################

And I want:
###################################################################
"FILEEXTENTION: [*.txt]"
"FILEEXTENTION: [*.sus]"
###################################################################

Is there a way to do this?

Thanks all!


See More: For Loop Ignore Wildcards

Report •

#1
February 23, 2011 at 09:00:48
FOR /F "delims=," %%P IN ("!FILE_EXTENTIONS!") DO (
  SET FILEEXTENTION=%%P
  ECHO "FILEEXTENTION: [!FILEEXTENTION!]"
)


Report •

#2
February 23, 2011 at 09:48:33
Hi Ivo,

Thanks!

I have tried that before asking here, and it only prints the first:
###################################################################
"FILEEXTENTION: [*.txt]"
###################################################################

Regards.


Report •

#3
February 23, 2011 at 12:22:41
:LOOP
FOR /F "tokens=1,* delims=," %%P IN ("!FILE_EXTENTIONS!") DO (
  SET FILEEXTENTION=%%P
  ECHO "FILEEXTENTION: [!FILEEXTENTION!]"
  SET FILE_EXTENTION=%%Q
)
if  defined file_extension goto :LOOP


Report •

Related Solutions

#4
February 24, 2011 at 03:22:23
Hi Ivo!

Thank for the post! It worked perfectly!

Regards!


Report •

Ask Question