We have an SFTP location which is shared by two processes. Now we have a situation when we need to filter based on the filenames before copying.

  1. ClientA12345.out
  2. ClientA44378.out
  3. ClientB23478.out
  4. ClientB72435.out

While copying files from there we are using two separate active batch processes.

When process for Client A runs we want to copy only files with prefix ClientA and same for ClientB.

I tried Rename command as it looked pretty straight forward but it does not allow for wildcards. Can anyone suggest me the resources to look for and guide with actual commands. would be very helpful.

  • 1
    please show your command which you used
    – Rahul
    Apr 13, 2016 at 6:35
  • I was trying to use something like this but did not work out. This one is for Client B Rename $<FTPPath>/HSBC*.out .tmp cd $<FTPPath> lcd $<LocalPath> mget ClientB.tmp mdel ClientB*.tmp Rename $<LocalPath>\HSBC*.tmp *.out
    – XS2coding
    Apr 13, 2016 at 9:25

2 Answers 2


AFAIK, it will not be possible to copy files from (s)FTP using wildcards.

Though, you can achieve the desired things by mounting the (s)FTP locally by using curlftpfs.

You can use wildcards then from locally mounted drive

  • Thanks but i need to write this script using a plan management tool and not locally. So i dont think this solution would help. Any other option.
    – XS2coding
    Apr 13, 2016 at 9:22
  • You should have mentioned that in your original question then.
    – SHW
    Apr 13, 2016 at 11:48

I faced some similar issue recently, and I noticed that lftp[1] does the job nicely with wildcards.

The systems I'm working on are vanilla redhat boxes, so I could imagine that this command could be available for you, too.

[1] http://lftp.yar.ru/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .