I have the following code:
@ECHO OFF
IF EXIST comandosAEjecutar.tpl (DEL comandosAEjecutar.tpl)
ECHO Procesando archivos a subir...
FOR /f "tokens=1 delims=," %%g IN (config.tpl) DO ECHO open %%g>> comandosAEjecutar.tpl
FOR /f "tokens=2 delims=," %%g IN (config.tpl) DO ECHO %%g>> comandosAEjecutar.tpl
FOR /f "tokens=3 delims=," %%g IN (config.tpl) DO ECHO %%g>> comandosAEjecutar.tpl
ECHO binary>> comandosAEjecutar.tpl
FOR /f "tokens=4 delims=," %%g IN (config.tpl) DO ECHO cd %%g>> comandosAEjecutar.tpl
FOR /f "tokens=5 delims=," %%p IN (config.tpl) DO @SET pathLocal=%%p
FOR /r . %%g IN (%pathLocal%\*.txt %pathLocal%\*.zip) DO ECHO delete %%~nxg>> comandosAEjecutar.tpl
FOR /r . %%g IN (%pathLocal%\*.txt %pathLocal%\*.zip) DO ECHO put %%~nxg>> comandosAEjecutar.tpl
ECHO bye>> comandosAEjecutar.tpl
ECHO Comienzo de la sesion FTP...
FTP -i -s:"comandosAEjecutar.tpl"
ECHO Finalizado.
PAUSE
EXIT
The actual problem is in the following lines:
FOR /f "tokens=5 delims=," %%p IN (config.tpl) DO @SET pathLocal=%%p
FOR /r . %%g IN (%pathLocal%\*.txt %pathLocal%\*.zip) DO ECHO delete %%~nxg>> comandosAEjecutar.tpl
FOR /r . %%g IN (%pathLocal%\*.txt %pathLocal%\*.zip) DO ECHO put %%~nxg>> comandosAEjecutar.tpl
I know that the variable “pathLocal” is being set correctly, as I did an ECHO and it showed the correct path, something like: \\red\C\pc\pc.com\serv\down\bol
The problem is that the two following lines are not interpreting the variable as a path, as they are producing no results, when I do have .txt and .zip files on that directory.
I believe your problem is the pathlocal variable being in the parenthesis, try moving it after the /r