Help with batch file...
Posted: 05 Jun 2010 00:10
Hi all,
I'm trying to automatize a task that consists on downloding every day some files from a ftp site.
I'm having a problem with my batch file and I ran out of ideas for trying to solve this.
My batch is like this:
@echo off&SETLOCAL
cd /D D:\FTP files\PCOMS
md %date%
cd %date%
FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date
:s_fixdate
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof
:s_print_the_date
echo Month:[%mm%] Day:[%dd%] Year:[%yy%]
ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%
echo user> FTP.txt
echo pass>> FTP.txt
echo cd directory1 >> FTP.txt
echo asc >> FTP.txt
echo hash >> FTP.txt
echo prompt >> FTP.txt
echo mget file1.hdf5 >> FTP.txt
echo mget file2.hdf5 >> FTP.txt
echo mget file3.hdf5 >> FTP.txt
echo mget file4.hdf5 >> FTP.txt
echo cd ../directory2 >> FTP.txt
echo asc >> FTP.txt
echo hash >> FTP.txt
echo prompt >> FTP.txt
echo mget %yy%%mm%%dd%.000000.hdf5 >> FTP.txt
echo bye >> FTP.txt
echo quit >> FTP.txt
call FTP.bat
FTP.bat just calls the ftp command:
ftp -d -s:FTP.txt -w:33000000 ftp.site.com > ftplog.txt
I run this and I just get:
Month:[06] Day:[05] Year:[]
I wait ages and nothing happens. Can someone give me a hand here please!
Cheers
Joao
I'm trying to automatize a task that consists on downloding every day some files from a ftp site.
I'm having a problem with my batch file and I ran out of ideas for trying to solve this.
My batch is like this:
@echo off&SETLOCAL
cd /D D:\FTP files\PCOMS
md %date%
cd %date%
FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date
:s_fixdate
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof
:s_print_the_date
echo Month:[%mm%] Day:[%dd%] Year:[%yy%]
ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%
echo user> FTP.txt
echo pass>> FTP.txt
echo cd directory1 >> FTP.txt
echo asc >> FTP.txt
echo hash >> FTP.txt
echo prompt >> FTP.txt
echo mget file1.hdf5 >> FTP.txt
echo mget file2.hdf5 >> FTP.txt
echo mget file3.hdf5 >> FTP.txt
echo mget file4.hdf5 >> FTP.txt
echo cd ../directory2 >> FTP.txt
echo asc >> FTP.txt
echo hash >> FTP.txt
echo prompt >> FTP.txt
echo mget %yy%%mm%%dd%.000000.hdf5 >> FTP.txt
echo bye >> FTP.txt
echo quit >> FTP.txt
call FTP.bat
FTP.bat just calls the ftp command:
ftp -d -s:FTP.txt -w:33000000 ftp.site.com > ftplog.txt
I run this and I just get:
Month:[06] Day:[05] Year:[]
I wait ages and nothing happens. Can someone give me a hand here please!
Cheers
Joao