Search code examples
windowsfileftpmove

Script Windows FTP move and rename file


basically i have a 2 files on my company FTP, i need the users to be able to click a script to swap the 2 files when they want.

FTP tree look like this:

/file1.vxml
/swap/file1.vxml

And here i need to connect to my ftp (on Windows), and rename /file1.vxml to /file2.vxml before moving then move it to /swap/ (to not overwrite /swap/file1.vxml). Then doing the opposite on /swap/file2.vxml and move it to the root.

i already have the connection :

open host.myhost.com
user myusername
mypassword
cd /
bye

but the thing i'm lacking is how to move and rename properly files on the ftp.


Solution

  • Use "REN" to rename files in FTP.

    ftp> REN FileA FileB
    

    Renaming and moving are the same thing essentially in FTP, you can move a file to a different folder by renaming it.

    ftp> REN Here ../There
    

    You'll probably have to download the first file back to your local server to save a copy, then rename the second file, and copy the file you downloaded back up to the server afterwards. I don't know of any FTP servers that support copying files within themselves.