```
::read in csv column 1 through 5
for /F "tokens=1,2,3,4,5 delims=," %%A in (file.txt) do (
::look for file extension foo in the first column
    IF EXIST findstr ".foo" \%%A(
        do some stuff >> Z:\completed.txt ) ELSE (
::try to change into a directory
            cd /d %%A
::go through all foo files and do something with them
            for /d %%F in (dir *.foo) do (
                do some stuff >> Z:\completed.txt 
            ) )
)

```

When I run this, the ELSE is "unexpected". I'm sure batch has weird bracket processing, but Notepad++ seems to think they are all valid.