Solved

Create ftp script from Directory Listing.

Posted on 2004-10-08
4
178 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now