Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename files in FTP using a single command

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 ?

like image 904
IT researcher Avatar asked Mar 25 '15 11:03

IT researcher


People also ask

How to rename or delete a file in FTP?

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.

Does rename command in SFTP work on different systems?

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.

How to rename files from Windows Command Prompt (CMD)?

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.

How do I rename a file using rnto?

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.


Video Answer


2 Answers

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
like image 130
MichaelS Avatar answered Sep 26 '22 04:09

MichaelS


Maybe with lftp:

lftp -e 'mv fileA fileB; quit'
like image 42
Mark Setchell Avatar answered Sep 22 '22 04:09

Mark Setchell