etm124
etm124

Reputation: 2140

Changing remote directory in bat file when FTPing

I have this current bat file:

echo user etm124> ftpcmd.dat
echo testing123>> ftpcmd.dat
echo cd C:\Documents and Settings\etm124\Desktop\>> ftpcmd.dat
echo mput *.txt>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -i -n -s:ftpcmd.dat ftp.DriveHQ.com
del ftpcmd.dat

As you can see, I am connecting to a free FTP service, and uploading all .txt files on my desktop. Before uploading, how do I change the remote directory in which I went to upload the files.

With the current script, it just uploads into the root directory. If I wanted to upload to a Text Files directory, how would I accomplish this?

Thanks.

Upvotes: 0

Views: 3842

Answers (2)

David Ruhmann
David Ruhmann

Reputation: 11367

Use the cd command. Currently, your cd command is trying to set the directory on the ftp server to C:\Documents and Settings\etm124\Desktop\.

  1. Pull the current cd command that you have out of the .dat file.

  2. Add a cd command to the .dat file to set the directory in which you want to upload the file into.

    cd C:\Documents and Settings\etm124\Desktop\
    echo user etm124> ftpcmd.dat
    echo testing123>> ftpcmd.dat
    echo cd ftpserver\folder\>> ftpcmd.dat
    echo mput *.txt>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -i -n -s:ftpcmd.dat ftp.DriveHQ.com
    del ftpcmd.dat
    

See http://www.cs.colostate.edu/helpdocs/ftp.html

Upvotes: 1

robotik
robotik

Reputation: 2007

i know that the question is about changing the remote directory, but if you want to change local directory while running your ftp script (as in the 3rd line of your sample code) use the lcd command.

echo lcd C:\Documents and Settings\etm124\Desktop\>> ftpcmd.dat

Upvotes: 0

Related Questions