cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming multiple files on FTP server

Former Member
0 Kudos

Hello

I am having SFTP server from which I am supposed to poll files. I have writtten a shell script to get the files from the SFTP location and had this OS level command called from XI adapter.

So the shell script first gets the file from SFTP server (since XI at present doesn't support SFTP) and then adapter will poll the same.

My problem is once i am done with my SFTP get i should be able to rename the files. But it seems rename can only rename one file at a time and can't rename multiple files at a time. i tried to use wild card characters but its of no use.

had anyone done renaming multiple files at a time on the FTP server? i was trying to use ls to get hte list of files and then loop on it but don't know how to do the same.

Thanks in advance.

Regards

Rajeev

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rajeev !

Maybe an idea could be within a script, launch an ls to gather the list of filenames in a file using ">" or ">>". Then process that file using loops and parse it to detect the filenames and create a new ftp script on the fly that makes the "rename $1 $2" for each file of the previously populated list, like

http://antonolsen.com/2005/03/23/read-a-file-with-bash/

  1. cat file.lst |while read line; do echo "rename $ $.old" >> new_ftp_script.sh; done

/tmp/file1.txt

/tmp/file with space.txt

#

then execute that script that will login again to the ftp, and send the proper rename commands.

Regards,

Matias.

Former Member
0 Kudos

Matias,

actually as stated earlier i want to execute the command under sftp> and not on Unix.

I tried doing in SFTP by using ! and then Unix command but it gave the list of files in my FTP server and not the list on the SFTP server.

Thanks and Regards

rajeev

Answers (2)

Answers (2)

Former Member
0 Kudos

You can't rename multiple files

hemant_chahal
Contributor
0 Kudos

Hi,

check this blog ,https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7036s [original link is broken] [original link is broken] [original link is broken]

thanks,

Hemant

Former Member
0 Kudos

Hemant,

That blog is really about SFTP and FTPS comparison and overall mechanism which we already know. My question is more specific about how to implement the same in the shell file.

Thanks and Regards

Rajeev Patkie