Copy files from FTP to local folder

Microsoft Windows xp professional w/serv...
August 11, 2010 at 02:55:22
Specs: Windows XP
Hi,

I need to copy the new files which ever comes on that particular current date, from ftp to local folder. Please help with any scripts.

Note:- This is a daily running job. so i need the files of sysdate or current date.

Thanks in Advance!!!


See More: Copy files from FTP to local folder

Report •


#1
August 11, 2010 at 04:19:15
You got at least 3 moving parts:

The local date layout.

The server date layout.

The server date setting.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
August 11, 2010 at 04:35:17
it's server date.

Let me give clear picture of my requirement.

Example:

file13.zip
file1002.zip
file89.zip

(There may be very old dated files also in the ftp).

If the last modified date of the files is current date, then I should copy those files to local folder.

Please provide me the code to perform this task.


Report •

#3
August 11, 2010 at 04:49:43
The point was, and still is, you need to provide the info requested in #1.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
September 14, 2010 at 09:14:42
I have a very similiar problem.
What I would like to do is write a batchfile that can be run once per day in scheduled tasks that will do the following:
log into an ftp
in one directory, download the newest file (by last mod date)
in another directory, download the newest 3 files (by last mode date)
in a third directroy, download the newest 2 files (by last mode date)
all of these directories are on the ftp

I don't want to compare the files in my local directory to those on the FTP if that can be avioded. (There are several files distributed in each directory each day, I only want the latest as of login.)
The server date is all that i am concerned about as far as what time to use to compare for last modified.

Any assistance would be greatly appreciated!


Report •

#5
September 15, 2010 at 01:21:39
This will get the 3 newest.

===========================================
@echo off > s.ftp & setLocal EnableDELAYedeXpansion

>> s.ftp echo o mysite.com
>> s.ftp echo user
>> s.ftp echo pass
>> s.ftp echo bin
>> s.ftp echo cd myfiles
>> s.ftp echo ls -t fileLIST
>> s.ftp echo bye

ftp -s:s.ftp

@echo off > newfile & set N=
for /f "tokens=* delims= " %%a in (fileLIST) do (
set /a N+=1
if !N! gtr 3 goto :done
>> newfile echo.%%a
)
:done

@echo off > s.ftp
>> s.ftp echo o mysite.com
>> s.ftp echo user
>> s.ftp echo pass
>> s.ftp echo bin
>> s.ftp echo cd myfiles
for /f "tokens=* delims= " %%a in (newfile) do (
>> s.ftp echo.get "%%a"
)
>> s.ftp echo bye

ftp -s:s.ftp


=====================================
Helping others achieve escape felicity

M2


Report •

#6
September 15, 2010 at 06:32:49
Thank you so much! I will give this a shot today.

Report •

#7
March 26, 2011 at 06:36:48
Hi M2,

I am posting this message to you directly, because most of the posts I have read related to my issue you have replied.

I have a process which populates and FTP site randomly thru out the day. I have the following Batch process which goes out to the FTP site and copies the files local, then renames them to an archive folder, then copies the original file to a different FTP folder, and then deletes the original file off the first FTP. The batch file to copy and rename runs on a task schedule ever 15 minutes. The problem I am having is that sometimes a new file will be placed on first FTP after the process starts, and then it gets deleted and not copied.

I have seen several posts about loops, and possibly comparing files from one directory to another before doing my delete but I dont know who to write a batch loop?

Here is my current Batch:
FTP/Copy/Rename/Del Batch loop

I have a batch process which goes to a FTP site and moves all the files to a local directory, then it renames the files and copies those to an archive, then it FTP those files to another FTP site. The last part of the process then DEL the files from the original FTP site.

The problem I am having is, the DEL process deletes new files that have not been copied to FTP directory because they were just added after batch process had begun.

I thought I could loop thru each file one at a time, do the mget/copy/mput/rename/del on one file at a time, which would prevent from deleting new files? Have not found a way to create this type of loop. Also, I dont have exact files names and have to use *.txt, *.set, and *.cse.

Here is the current Batch:
ftp -s:D:\Red\ftpgetsetfiles.txt xxx.xxx.xxx.xxx

COPY "D:\Red\SET\*.set" "D:\Red\SETArchiveRename"

ftp -s:D:\Red\ftpputsetfiles.txt xxx.xxx.xxx.xxx

FOR /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "D:\Red\SETArchiveRename\*all.set" *all_%%e-%%f-%%g.set

COPY "D:\Red\SETArchiveRename\*.set" "D:\Red\SETArchive"

ECHO Y | DEL D:\Red\SETArchiveRename\*.set

ECHO Y | DEL D:\Red\SET\*.set

ftp -s:D:\Red\ftpdelsetfiles.txt xxx.xxx.xxx.xxx


Report •

#8
March 26, 2011 at 13:20:20
"I dont know who to write a batch loop?"

:labelname
echo looooop
pause
goto labelname

Happy is ONE who says I am an OttoMAN.


Report •

#9
April 1, 2011 at 07:36:42
I thought I could write a loop within the FTP script, but you can't.

Any suggestions, how to copy and then delete one file at a time from FTP?


Report •

#10
April 2, 2011 at 05:19:48
OP couldn' be bothered to reply for 8 months.

Start a new thread with an appropriate subj & clear description of req.


=====================================
Life is too important to be taken seriously.

M2


Report •


Ask Question