Reputation: 351
I want a batch file to write another batch file to every sub directory, run the batch file and then delete it. The problem comes when writing a lot of information within the for loop. Is there any more effective way other than to chain &&? Also I am not sure whether writing commands to a batch file would screw up the batch file as it runs?
for /D /R "%cd%" %%d IN (*) do set thing=%%~nd && echo @ECHO OFF>%%d\Desktop.bat && call %%d\Desktop.bat && del /Q %%d\Desktop.bat
Upvotes: 0
Views: 87
Reputation: 124696
You could do something like (untested):
for /D /R ... IN ... DO CALL :PROCESS %%d
GOTO END
...
:PROCESS
set thing=%~n1
echo @echo off>%1\Desktop.bat
call %1\Desktop.bat
del /q %1\Desktop.bat
GOTO :EOF
...
END:
... etc ...
Upvotes: 1