Hi,
I have a batch file that ftps. Here is what it does.
1. It creates a directory listing file of all directories in the current directory.
2. It changes the current directory to each sub directory.
3. It creates a file listing file of all files in the subdirectory.
4. It ftps each file in the subdirectory using the file listing file as its file source to ftp.
It partially works, but only works for the last subdirectory.
I need someone to tell me where my logic is wrong.
Thanks
I have a batch file that ftps. Here is what it does.
1. It creates a directory listing file of all directories in the current directory.
2. It changes the current directory to each sub directory.
3. It creates a file listing file of all files in the subdirectory.
4. It ftps each file in the subdirectory using the file listing file as its file source to ftp.
It partially works, but only works for the last subdirectory.
I need someone to tell me where my logic is wrong.
Code:
SET _SourceDir=C:\red
DIR /A:D /B > filedir.txt
SET _SourceFile=filedir.txt
for /F %%B in (%_SourceFile%) do (
cd /d %_SourceDir%\%%B
dir /A:-d /B > %%Bfiles.txt
SET _UploadFiles=%%Bfiles.txt
for /F %%G in (%_UploadFiles%) do (
ECHO open serverip > %_SourceDir%\%%B\script_ftp.txt
ECHO user username password >> %_SourceDir%\%%B\script_ftp.txt
ECHO put %%G >> %_SourceDir%\%%B\script_ftp.txt
ECHO bye >> %_SourceDir%\%%B\script_ftp.txt
ftp -v -i -n -s:%_SourceDir%\%%B\script_ftp.txt
)
)
cd /d %_SourceDir%
Thanks