To rename a File in a FTP using command line we need to do following.
ftp
open example.com
username
password
cd myfolder
rename myfile.txt mynewfile.txt
close
quit
So is there any command line or script logic where i can do it in a single line ?
To rename a file that already exists in your FTP directory. In this case the file temp2 is being renamed to temp22. 250 RNTO command successful. You can delete file using command delete.
Apparently the renamecommand in sftp does NOTwork when the source and target are on different file systems. I see this behaviour in RedHat6, SLES9, and more.
by Srini. We can use the command rename to rename files from windows command prompt (CMD). Find below syntax of the command with examples. Syntax of rename command: rename file_path new_name. Example: rename d:datafile1.doc file2.doc. After executing the above command we’ll have file2.doc in the folder d:data.
To rename a file that already exists in your FTP directory. In this case the file temp2 is being renamed to temp22. 250 RNTO command successful. You can delete file using command delete. To UPLOAD a file, type put C:\my-www\default2.htm, (Location of your file on your computer) and hit enter.
You could create an FTP script file in which you list all your commands and execute it from your bat file in a single line like this:
Bat file:
FTP -v -i -s:C:\PathTo\ftpscript.txt
ftpscript.txt:
open example.com
username
password
cd myfolder
rename myfile.txt mynewfile.txt
disconnect
bye
Maybe with lftp
:
lftp -e 'mv fileA fileB; quit'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With