Get Date of Single File in FTP

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
wmorais
Posts: 2
Joined: 19 Dec 2008 07:21

Get Date of Single File in FTP

#1 Post by wmorais » 19 Dec 2008 07:35

How do I retrieve the date of a specific file in a folder on FTP?

tks

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 19 Dec 2008 22:55

wmorais,

From within a FTP session type:

Code: Select all

ftp> dir index.php

200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-rw---- 1 441219 15000 2850 Dec 6 03:34 index.php

226 Transfer complete
ftp: 66 bytes received in 0.05Seconds 1.40Kbytes/sec.

or

Code: Select all

ftp> quote mdtm index.php

213 20081206083402

Date and time are in the number after the 213, i.e. YYYYMMDDhhmmss

DosItHelp? :wink:

wmorais
Posts: 2
Joined: 19 Dec 2008 07:21

Get Date of Single File in FTP

#3 Post by wmorais » 22 Dec 2008 05:55

First, thanks for the reply!

I need to put it in a variable in my code, but I don't know how.
something like this:

:: BEGIN

:: ...

set dir_arq = E:\TMP_DIR
set nome_arq = myfile.txt

:: MK FTP CONNECTION FILE
echo open FTP_SERVER > ftp_cmd.txt
echo USER>> ftp_cmd.txt
echo PWD>> ftp_cmd.txt
echo cd DIR\SUB-DIR>> ftp_cmd.txt
echo ascii>> ftp_cmd.txt
echo lcd %dir_arq%>> ftp_cmd.txt

HERE: I NEED TO PUT THE MODIFICATION DATE INTO A "VARIABLE"
TO USE IT IN ANOTHER PLACE OF CODE

echo get %nome_arq%>> ftp_cmd.txt
echo disconnect>> ftp_cmd.txt
echo bye>> ftp_cmd.txt

:: FTP CONNECTION
ftp -i -v -s:ftp_cmd.txt

:: ...

:: HERE: I NEED TO USE THE "VARIABLE" ABOVE FOR A COMPARISON

:: ...

:: END

Can you help me?

tks

Post Reply