Reputation: 31
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
Reputation: 1
try something like this:
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
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)
install curlftpfs
sudo apt-get install curlftpfs
create the mount folder
sudo mkdir /mnt/ftp_remote_root
mount remote ftp on folder
sudo curlftpfs -o allow_other -o user="USERWITH@CHARACTERTOO:PASSWORDTOACCESSUSER" ftp://my_ftp_server.com /mnt/ftp_remote_root/
jump into desired ftp remote folder
cd /mnt/ftp_remote_root/path/to/folder
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
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