0

I have this 'win32 shell scipt' (?):

FOR %%filename IN (*.txt) DO (
...
)

I would like to replace the set (*.txt) with a set of strings defined as variable at the beginning of the script. Could someone please point me to the appropriate documentation of 'win32 shell scipt' or even better provide some 'code'?

5
  • Check this post: stackoverflow.com/questions/1707058/… Commented Jul 23, 2014 at 15:25
  • Thanks I'll have a look. Commented Jul 23, 2014 at 15:40
  • This helped thanks. Do you know how to use strings that contain spaces? Commented Jul 23, 2014 at 16:10
  • Provide some of the strings in your question, to help us provide working code. Commented Jul 23, 2014 at 16:14
  • Just use a different delimiter (delims option in FOR). You may use, for example, a comma or a semicolon. Commented Jul 23, 2014 at 16:16

1 Answer 1

1

Not clear the requirements, but, as requested, some code

@echo off
  setlocal enableextensions disabledelayedexpansion

  :: the normal strings
  set "var1=one"
  set "var2=this is a test"
  set "var3=two"

  :: a set of files
  set "var4=*.cmd"

  for %%a in ("%var1%" "%var2%" "%var3%" "%var4%") do echo %%a, %%~a

And, of course, you should see for /?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.