So I am trying to create a batch file, that gets all the files in deletesrc
and find's if it's name matches any folder in deletedest
. To accomplish this, I have tried to generate a list of file names in deletesrc
which is stored in deletefiles
(in the format "first" "second" "third file"
). Then I intend to loop through each folder in deletedest
and check for it's existence in deletesrc
(using this). So far I have managed:
setlocal enabledelayedexpansion
set "deletesrc=F:\Delete Source"
set "deletedest=C:\Users\Spaced Name\Delete\Dest"
set "deletefiles=" ::I think this is useless, but I would prefer it to be here
for /R "%deletesrc%\" %%i in (*) do (
set "deletefiles=!deletefiles!^"%%i^" "
::random comment that is source of error
)
set deletefiles=!deletefiles!:rTrim
echo !deletefiles!
The main problem is, I keep getting ) was unexpected at this time
.
Placing an echo test
as the first thing within the loop, does not change the output, implying the loop is not run and the error encountered first. Placing an echo
just before the loop, does produce output and the error immediately after it.
If there are any syntax standards or things I should/should not be doing that do not answer the question, I would like to know.