FTP connect and move file to Network Drive

August 3, 2010 at 23:53:03
Specs: Windows XP
Please assist me in writing DOS program for my scenario is:

Login to a FTP with the User name and Password written inside the script, after logged in to the FTP get the Recent file by date and move that one file to a Network Shared path.

Example:

- Login to FTP
- identify the File which is recent by date.
- Move the file to a Network Drive (\\10.10.10.10\backup\)


See More: FTP connect and move file to Network Drive

Report •

#1
August 4, 2010 at 10:32:56
[1] It's either DOS or XP; not both.

[2] Do you mean the "most recent" file? Or what?


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

M2


Report •

#2
August 4, 2010 at 11:51:09
sorry if I would have confused it , to clarify your questions and also edited my question:

1) It is Windows Operating System.
2) yes it Most Recent File.


Report •

#3
August 4, 2010 at 12:35:04
@echo off & setLocal EnableDELAYedeXpansion

>  d.ftp echo o mysite
>> d.ftp echo user
>> d.ftp echo pass
>> d.ftp echo bin
>> d.ftp echo ls -t filelist
>> d.ftp echo bye

ftp  -s:d.ftp

for /f "tokens=*" %%a in (filelist) do (
set R=%%a
goto :done
)
:done

>  d.ftp echo o mysite
>> d.ftp echo user
>> d.ftp echo pass
>> d.ftp echo bin
>> d.ftp echo get "!R!"
>> d.ftp echo bye

ftp  -s:d.ftp


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

M2


Report •

Related Solutions

#4
August 4, 2010 at 12:42:20
Thanks for the quick response and your valueable time:

That was very neat, Please help me in completing the complete scenario I am having : writing it as .BAT File.

Step 1: connecting to ftp 10.10.10.10, User Name: ftp, Password: ftp, Folder: \folder1\

Step 2: Find the Most Recent File.

Step 3: Move the file to a Network shared folder \\10.10.10.11\backup.

Also please write the Code comments for me to understand the code step by step.

Thanks so much in advance.


Report •

#5
August 5, 2010 at 00:10:23
[1] I don't have a net work, so I'm no help with \\10.10.10.11\backup

If your network drive is mapped, you can start your script with something like:

pushd n:\bakup

[2] Do you want to MOVE or COPY? Not the sane thing.


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

M2


Report •

#6
August 5, 2010 at 01:33:50
1) ok that would also help I will map the Network Drive to my computer like you mentioned and

[2] I want to copy.

Please send me code the comments so that I can understand step by step the Batch code you send.


Report •

#7
August 5, 2010 at 01:56:41
@echo off & setLocal EnableDELAYedeXpansion

pushd n:\bakup

>  d.ftp echo o mysite
>> d.ftp echo user
>> d.ftp echo pass
>> d.ftp echo bin
>> d.ftp echo ls -t filelist
>> d.ftp echo bye

ftp  -s:d.ftp

for /f "tokens=*" %%a in (filelist) do (
set R=%%a
goto :done
)
:done

>  d.ftp echo o mysite
>> d.ftp echo user
>> d.ftp echo pass
>> d.ftp echo bin
>> d.ftp echo get "!R!"
>> d.ftp echo bye

ftp  -s:d.ftp


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

M2


Report •

#8
August 5, 2010 at 08:08:40
Hey M2,

Thanks for that code. I was of great help. please help me tweak these two issues...

1) While I run the statement ls -t filelist
I am getting Error - permission Denied so I changed the statement to dir -t filelist.

2) This runs but it takes up some random file name which is not Most recent file and it takes the file with the file properties like this"-rw-rw-rw- 1 user group 7482 Oct 18 2008 dataslice"

Please help me fix these issues.

let me know if you are not clear with my questions. Thanks so much for all the help so far :)


Report •

#9
August 5, 2010 at 08:28:38
The solution is to get permission to use ls.


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

M2


Report •

#10
August 11, 2010 at 10:01:16
Hey M2,

Thanks for that timely help, I have got another modification to make now to the existing Code:

This is what I have to accomplish now:

Step 1: connecting to ftp 10.10.10.10, User Name: ftp, Password: ftp, get to the FTP Folder: \folder1\

Step 2: Find the today (System Dated Files).

Step 3: Copy the files to my System folder D:\myfolder\

Also please write the Code comments for me to understand the code step by step.
Thanks so much in advance. Please help me in this situation.

Thanks so much for your time and all the help so far :)


Report •

#11
August 11, 2010 at 10:57:03
To get "today's" file[s] you need to know the time & date conventions on both machines.


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

M2


Report •

#12
August 11, 2010 at 11:28:23
I have to identify the Todays Date in FTP Identify the files dated Today and put it to a Drive in my machine.

I hope I answered your question.


Report •

#13
August 12, 2010 at 01:50:53
After connecting to the FTP, what is the command I have to issue to find out the FTP date format ?

Please help me in building the code for the requirement I have mentioned in the Response # 10.


Report •

#14
August 12, 2010 at 02:52:17
ls -ltr

Next you need to figure out the settings.


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

M2


Report •

#15
August 12, 2010 at 03:19:49
This is the sample output of ls -ltr in my FTP:

-rw-rw-rw- 1 user group 12345 Apr 1 2008 123.zip
-rw-rw-rw- 1 user group 12345 Jan 18 22:20 mount.txt

Please guide me further with my requirement.


Report •

#16
August 16, 2010 at 02:34:16
Hi M2,

Awaiting Response Please Help...

Regards,
Mohamed


Report •

#17
September 20, 2010 at 05:49:18
Hi M2 \ All,

Awaiting Response Please Help...


Report •

Ask Question