Skip to Content
author's profile photo Former Member
Former Member

Issue with OS Command to handle multiple files in File Adapter

Hi,

A separate process creates a couple of files on PI file system (say Message_1.tmp, Message_2.tmp and so on).

In my scenario, I when I create a target file using receiver file adapter, these tmp files should be renamed to .xml or be deleted. I am using two separate file adapters for renaming and deletion.

In either case, if I use wildcards like *, it does not work.

i.e. the following OS command

rm /path/Message_1.tmp

deletes the file Message_1.tmp

but the command

rm /path/Message_*.tmp

does not work. I need a command that can delete all .tmp file starting with "Message_".

Same issue is with renaming files.

mv /path/Message_1.tmp /path/Message_1.xml

works but

mv /path/Message_*.tmp /path/Message_*.xml

does not work.

Any help is highly appreciated.

Thanks.

Regards,

Riyaz

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Oct 05, 2009 at 12:00 PM

    Hi, Riyaz

    OS command mv /path/Message_.tmp /path/Message_.xml can't rename multiple files. You must create a script and using it in your communication channel.

    However rm /path/Message_1.tmp it's correct. Perharps you need to put full path...

    Regards, Carme

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 05, 2009 at 12:15 PM

    to deletes use

    rm /path/Message_[0-9]\.tmp
    

    "\." (backslash then dot with no space)

    No backslash before the dot would mean just any single character

    above command

    removes any files starting with "Message" and then any 1 number(extension is .tmp).

    u can also use ?(-means any character) instead of

    [0-9]

    .

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 05, 2009 at 12:49 PM

    can you try

    rm -r /path/Message_*.tmp

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.