Solved

Create ftp script from Directory Listing.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

22 Experts available now in Live!

Get 1:1 Help Now