Solved

Create ftp script from Directory Listing.

Posted on 2004-10-08
4
186 Views
Last Modified: 2012-08-13
Hi, I am need to do a script file to delete remote files via ftp:

I want to use a directory listing as the base of the text file (called script.txt)
I will shell to a batch file (called logit.bat that does this):

CD "C:\scans\"
dir /B > script.txt

Now say the result of the batch is:

BELLE-16251KTX.TIF
BELLE-16051SCO.TIF
CG-76690BSR.TIF
CG-76690BHB.TIF
OA-2700USR.TIF
OA-2710KTX.TIF

I want to amend this script.txt file to have the necessary commands to delete the files on the remote server.

the end result of the script.txt file would be :

user bco passwd pArtner5
binary
DEL BELLE-16251KTX.TIF
DEL BELLE-16051SCO.TIF
DEL CG-76690BSR.TIF
DEL CG-76690BHB.TIF
DEL OA-2700USR.TIF
DEL OA-2710KTX.TIF
bye

I can handle the rest from here.
So basically i just need to know how to add the following to the top of the file:

user bco passwd pArtner5
binary

The following infront of the already existing lines:
DEL

The following at the very end of the file.
bye



0
Comment
Question by:jerrycsakanyjr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
naiea1231 earned 500 total points
ID: 12265878
This will do what you want, written in vbscript so just save it as a .vbs in the same directory as script.txt, it will override the contents of the original file

'open script.txt
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("script.txt")

Result = "user bco passwd pArtner5" & vbCrLf & "binary"

Do Until oTS.AtEndOfStream
Result = Result & vbCrLf & "DEL " & oTS.ReadLine

Loop

Result = Result & vbCrLf & "bye"

oTS.Close


Set oTS = oFSO.OpenTextFile("script.txt",2)

oTS.Write(Result)

oTS.Close



Let me know how it goes

James
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12266288
You only need the file created?, or you need how to execute it via ftp in VB .NET?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question