1

I have a root path for which I have sub-directories. Within each sub-directory is a number of files for which I need to process.

I have the current batch script:

@echo off

for /d %%K in (C:\Users\Proxy\*) do (

    echo %%K
    set /a x=0

    for %%F in (%%K\*) do (

        echo %%F
        echo %x%
        set /a x+=1
    )

)

For each subdirectory in root path, echo file name.

However I noticed that my output is missing files and is not completing the loop properly.

What is going wrong?

I am quite new to batch scripting so excuse my inexperience.

Bodz
  • 37
  • 8
  • 1
    "properly" means "as I expected" -- but you've not shown us neither what you expected nor what you observed. From what you *have* shown us, two conclusions are obvious. The first is that if the "missing files" of which you complain are in directorynames which contain spaces, then the `%%K\*` in the `for %%F` line should be `"%%K\*"` (quoting a file/directoryname/afn causes it to be treated as one string rather than 2 or more space-separated strings) and the other is that changing a variable within a code block (parenthesised series of lines) is #1 FAQ - see many SO items on `delayed expansion` – Magoo Aug 22 '17 at 15:18
  • Take a look [Batch File : Read File Names from a Directory and Store in Array](https://stackoverflow.com/questions/45809295/batch-file-read-file-names-from-a-directory-and-store-in-array/45812031#45812031) – Hackoo Aug 22 '17 at 16:07

0 Answers0