Rename multiple files using ftp - 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.

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.

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

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.

Use the following command:
ren *.txt *.done

Related

Using gunzip on Windows in command line

I need to use gunzip (which is the decompression tool of gzip) in a terminal on Windows
I've downloaded gzip from here (first download link)
I installed it and added its /bin folder to my PATH variable, the gzip command works but gunzip is not even executable so I can't use it
gunzip content:
#!/bin/sh
PATH=${GZIP_BINDIR-'c:/progra~1/Gzip/bin'}:$PATH
exec gzip -d "$#"
Thanks
I made it work
As I said I needed to install gzip and add its /bin folder to my PATH variable
Then edit the ProgramFiles/GnuWin32/bin/gunzip file using this (replace everything):
#echo off
gzip -d %1
and save it to .bat format so you now have a gunzip.bat file in your /bin folder
Now I can use gunzip in a terminal :)
I have been using MobaXterm software in my local machine (Windows).
It works like Putty and WinSCP together and opens the local desktop in linux mode, thus it is easy for me to gunzip the *.gz type files.
The code you posted is bash, suitable for linux.
You need to make a dos/command version of it to be run on windows
i.e.
REM THIS IS CMD
PATH=c:/progra~1/Gzip/bin;%PATH%
gzip.exe -d "%*"
Since it is a different build anyway it is hard to say if all command line parameters are the same you are used with linux so maybe even with this .cmd or .bat you will not be able to work at the same way you do in a linux environment.

tar -zxvf cannot unzip file

here's the problem:
First step
transfer the *.gz file to the remote host using ftp, the code below
open $IP
user nfc nfc123
bin
passive
cd /nfc/APPBAK
put $FULLNAME $DESTFILE
cd $DESTDIR
tar -zxvf $local_filename
quit
FTPIT
Second step
tar -zxvf $local_filename
but it says:
"?Invalid command. "
Should I change the mode of of the *.gz file first, any help will be appreciated.
You are trying to run the tar command inside FTP, as far as I can see, rather than in the shell after you've fetched the file with FTP. It is confusing since some shell commands, like cd, seem to work in FTP too, but the cd command actually attempts to change directory on the remote machine (you need lcd to change directory on the local machine).
Put simply, tar isn't a valid FTP command, which is why you get the ?Invalid command error.
try this one::
tar -xvf $local_filename
Please make sure that file has right permissions.

How can I FTP many files I have listed in a TXT?

I have a list of files inside a TXT file that I need to upload to my FTP. Is there any Windows Bat file or Linux shell script that will process it?
cat ftp_filelist | xargs --max-lines=1 ncftpput -u user -p pass ftp_host /remote/path
You can use the wput command.
The syntax is somewhat like this
wput -i [name of the file.txt]
Go through this link
http://wput.sourceforge.net/wput.1.html
It works for linux.With this it will upload all the URLs given in the text file onto your ftp server one by one.
You may want to check out Jason Faulkners' batch script about which he wrote here.

SCP files from an IP

I have a folder of files on an IP that I want to download.
Can I do this using PUTTY?
I've tried using
scp user#servername:/home/folder-to-download C:\temp\
but it doesn't seem to work
If you're using putty, the command is pscp. Paul's -r tip is also relevant:
pscp -r user#servername:/home/folder-to-download C:\temp\
You need to make it a recursive copy:
scp -r user#servername:/home/folder-to-download C:\temp\
See the scp man page for a list of possible options, including -r.

Archive/Compress Command FTP Through Terminal?

Is it possible to compress a folder and create a .zip on my server through a command in terminal via FTP? Is there a archive command? Thanks.
Welcome to stackoverflow.
What I believe you want to do is ssh onto your server and use the tar command.
tar -cf archive.tar contents/
Takes everything from contents/ and puts it into archive.tar
You can find more information here.

Resources