user1071005
user1071005

Reputation: 31

Rename multiple files using ftp

I have a set of files in my ftp folder. I have access to only ftp mode. I want to rename those files with extension .txt to .done

Ex:

1.txt, 2.txt, 3.txt 

to

1.done, 2.done, 3.done

Only rename command is working in this ftp. I am expecting something like

rename *.txt *.done 

to rename them all in a single command.

Upvotes: 3

Views: 18596

Answers (4)

Apurv Pandey
Apurv Pandey

Reputation: 237

Use the following command:

ren *.txt *.done

Upvotes: 0

Milan
Milan

Reputation: 1

try something like this:

the following example move/rename files on the FTP server

for f in $(lftp -u 'username,password' -e 'set ssl:verify-certificate no; ls /TEST/src/*.csv; quit' ftp.acme.com| awk '{print $9;}'); do lftp -u 'username,password' -e "set ssl:verify-certificate no; mv /TEST/src/$f /TEST/dst/$f; quit" ftp.acme.com; done

note: use .netrc to store username and password.

Upvotes: 0

Lorenzo Eccher
Lorenzo Eccher

Reputation: 301

Hallo to all,

Even if the question is quite old, I think could be usefull for others to read my suggestion.

I found a great and easy solution combining curlftpfs, "A FTP filesystem based on cURL and FUSE" as they define it, and rename linux and unix multi rename tool.

I tested on linux mint 17 (and I think it should work in other debian based distributions)

  1. install curlftpfs

    sudo apt-get install curlftpfs
  2. create the mount folder

    sudo mkdir /mnt/ftp_remote_root
  3. mount remote ftp on folder

    sudo curlftpfs -o allow_other -o user="USERWITH@CHARACTERTOO:PASSWORDTOACCESSUSER" ftp://my_ftp_server.com /mnt/ftp_remote_root/
  4. jump into desired ftp remote folder

    cd /mnt/ftp_remote_root/path/to/folder
  5. rename as you need files (-v shw new names, -n show interested files, omitt them to rename files)

    sudo rename -v -n 's/match.regexp/replace.regexp/' *.file.to.change

It could took few seconds because it works on network.

I think it is really powerfull and easy to use.

Let me know if you find any problems.

Bye

Lorenzo

Upvotes: 1

Yuri
Yuri

Reputation: 2028

In short: You can't. FTP is very basic and does not support mass renaming. You can either write a small script for it, or download some helper software, such as the one here.

Upvotes: 3

Related Questions