0

I was looking for a batch file, that saves one of listed files as variable, then proceeds to get some information about it and then set him as already listed, and then list every other file until there are none left. Important is to make %FILE% as single file (ex.: C:\folder\file.ext) I was trying this:

@echo off
:loop
for %%x in (%dir%\*) do set FILE=%%x
if %FILE%=%alreadyusedfile% goto loop
goto scan

:scan
echo Now scanning %FILE%
(do some things here)
set alreadyusedfile=%alreadyusedfile% %FILE%
goto loop

But seems it doesn't work. Any ideas?

rifteyy
  • 50
  • 6
  • Does this answer your question? [Arrays, linked lists and other data structures in cmd.exe (batch) script](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script) – T3RR0R May 21 '21 at 11:27

1 Answers1

1

You need to process the files within the loop which you have two options.

Using the CALL command to make your code work like a function.

@echo off
for %%x in (%dir%\*) do call :scan "%%x"
goto :eof

:scan
echo Now scanning "%~1"
(do some things here)
Goto :eof

Or do everything within the FOR construct.

@echo off
for %%x in (%dir%\*) do (
    echo Now scanning %%x
    do some things here
)
Squashman
  • 13,649
  • 5
  • 27
  • 36