Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 647 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch script for loop won't set variable

#1
I have a batch script trying to execute out of anthill to get the folder names containing plsql to be compiled.

for /F %%a in ('dir /b D:\AHP_WorkDir\var\jobs\projects\rprt_test\rprt_test\plsql') do (
set FOLDER=%%a
echo *** PROCESSING FOLDER %FOLDER% ***
)

This echos
*** PROCESSING FOLDER ***

as if the variable is not getting set, which I'm pretty sure is true after spending way too long on verifying it

So...What am I doing wrong?
Reply

#2
_This is essentially a duplicate of a [question asked earlier today](

[To see links please register here]

). Here's my answer from said question..._

You'll want to look at the [EnableDelayedExpansion](

[To see links please register here]

) option for batch files. From the aforementioned link:

> Delayed variable expansion is often useful when working with FOR Loops. Normally, an entire FOR loop is evaluated as a single command even if it spans multiple lines of a batch script.

So your script would end up looking something like this:

@echo off
setlocal enabledelayedexpansion

for /F %%a in ('dir /b D:\AHP_WorkDir\var\jobs\projects\rprt_test\rprt_test\plsql') do (
set FOLDER=%%a
echo *** PROCESSING FOLDER !FOLDER! ***
)

As an alternative, just use the `%%a` variable in your inner loop, rather than creating a new variable.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through