bulk renaming of files in sftp using script

Hi,

Am using sftp (dsa method) to transfer 20 files from one server(sftp) to another (local). After the transfer is complete the files in the sftp server has to be renamed from .txt extension to .done extension ( aa.txt to aa.done, bb.txt to bb.done and likewise...).
I tried rename command but it works for only renaming of single file.
Can anyone help me in renaming all the 20 files in sftp using sample script.:frowning:

something like this may work ...

#!/usr/bin/ksh
for i in `ls *.txt`
do
sftp user@hostname << EOF
cd <PATH>
put $i `basename ${i} txt`done
EOF
done

ok thank you so much :slight_smile: wil try ... but wen we use put command and place the files, the sftp server will now have the older .txt files and the new .done files which are placed now using ur above script. I need to rename the files in the server not to place a copy of .done.
This process is done because after the admin see the .done renaming of files they place the next day files so that i can take the files by using ls *.txt
In the above process which u have said will take all the files (older and newer ones) also rite as files would not be renamed.

#!/bin/sh
# wow this is easy
for file in `ls *.txt`
do
     scp $file foo@bar.com:/some/where/`basename txt ${file}`.done
done

thanx ... wil try and let u know ... :slight_smile: