Batch Script to locate specified path on FTP server
Moderator: DosItHelp
-
- Posts: 5
- Joined: 09 Jul 2015 04:00
Batch Script to locate specified path on FTP server
Hi Team,
Please need your valuable support to resolve my concern.
Request : I want download files from FTP server but here requirement is we needs to specify the path basis on system date.
Ex : FTP path location -> cd /pgdata/2015-07-09<This folder having today's date> so this date will change every day
Here want to make the date folder name automate format (YYYY-MM-DD).
I have tried several ways but not able to crack kindly suggest.
FTP Text File
--------------
open XX.XXX.XX.XX
ftpuser
ftpuser123
cd /pgdata/2015-07-09<YYYY-DD-MM>
lcd d:\Reports
binary
prompt
Please need your valuable support to resolve my concern.
Request : I want download files from FTP server but here requirement is we needs to specify the path basis on system date.
Ex : FTP path location -> cd /pgdata/2015-07-09<This folder having today's date> so this date will change every day
Here want to make the date folder name automate format (YYYY-MM-DD).
I have tried several ways but not able to crack kindly suggest.
FTP Text File
--------------
open XX.XXX.XX.XX
ftpuser
ftpuser123
cd /pgdata/2015-07-09<YYYY-DD-MM>
lcd d:\Reports
binary
prompt
Re: Batch Script to locate specified path on FTP server
Getting the date, and into a certain format, is one of the most FAQ on the internet.
You will find dozens of ways if you search on this forum a little.
You will find dozens of ways if you search on this forum a little.
-
- Posts: 5
- Joined: 09 Jul 2015 04:00
Re: Batch Script to locate specified path on FTP server
I have not found perfect solution, Any one please suggest me if it's possible to make it.
Re: Batch Script to locate specified path on FTP server
Open up a command prompt and type:echo %date%
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Script to locate specified path on FTP server
http://stackoverflow.com/questions/2030 ... 116#203116
Specifically, the third one with the wmic code. Guaranteed to work regardless of where in the world you live.
Specifically, the third one with the wmic code. Guaranteed to work regardless of where in the world you live.
-
- Posts: 5
- Joined: 09 Jul 2015 04:00
Re: Batch Script to locate specified path on FTP server
How to call this ECHO command on mentioned remote path FTP script, Please revert me if possible.
Re: Batch Script to locate specified path on FTP server
Test this:
Code: Select all
@echo off
rem The four lines below will give you reliable YY DD MM YYYY HH Min Sec MS variables in XP Pro and higher.
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" & set "MS=%dt:~15,3%"
set "datestamp=%YYYY%-%DD%-%MM%"
set "ftpHost=XX.XXX.XX.XX"
set "ftpUser=ftpuser"
set "ftpPwd=ftpuser123"
set "ftpRemoteDir=/pgdata/%datestamp%"
set "ftpLocalDir=%cd%"
(
echo open %ftpHost%
echo %ftpUser%
echo %ftpPwd%
echo lcd d:\Reports
echo cd %ftpRemoteDir%
echo binary
echo dir
echo bye
)>"%ftpLocalDir%\temp.ftp"
ftp.exe -i -s:"%ftpLocalDir%\temp.ftp"
del "%ftpLocalDir%\temp.ftp"
pause
-
- Posts: 5
- Joined: 09 Jul 2015 04:00
Re: Batch Script to locate specified path on FTP server
Wow.. Awesome Bro.. It's working perfectly
But downloading is not happening, I have included mget command and reports are reflecting on screen only but not downloading.
Please need your support to find the solution for downloading as well below sample output details for your reference.
ftp> mget *.csv
200 Switching to Binary mode.
mget TDR_UTIBA_20150728_0014.csv? bye
mget TDR_UTIBA_20150728_0029.csv? mget TDR_UTIBA_20150728_0044.csv? mget TDR_UTIBA_20150728_0059.csv?
But downloading is not happening, I have included mget command and reports are reflecting on screen only but not downloading.
Please need your support to find the solution for downloading as well below sample output details for your reference.
ftp> mget *.csv
200 Switching to Binary mode.
mget TDR_UTIBA_20150728_0014.csv? bye
mget TDR_UTIBA_20150728_0029.csv? mget TDR_UTIBA_20150728_0044.csv? mget TDR_UTIBA_20150728_0059.csv?
-
- Posts: 5
- Joined: 09 Jul 2015 04:00
Re: Batch Script to locate specified path on FTP server
Please ignore my earlier comments as I'm able to generate and download, My requirement is fulfilled 10000%.
Thanks a TON for your such a wonderful support.
Thanks a TON for your such a wonderful support.