You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dermoritz <ta...@hotmail.com> on 2014/10/27 18:12:29 UTC

How to split to files and add number to output file names (not overwrite)

I have a route that splits large files into smaller ones. All split files
should be written to same directory. The default behavior of file endpoint
(producer) seem to overwrite always.
Is there an easy way to let the file producer do a simple rename by adding a
counter to file name? Like in OS if you do copy/paste on a file and OS does
auto rename by adding (copy-1...).



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-split-to-files-and-add-number-to-output-file-names-not-overwrite-tp5758116.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to split to files and add number to output file names (not overwrite)

Posted by dermoritz <ta...@hotmail.com>.
Thx claus, but i read those sites already. The problem was i couldn't find
any hint on adding a number or count on the files.

But Stackoverflow helped:
http://stackoverflow.com/questions/26593037/how-to-split-to-files-and-add-number-to-output-file-names-not-overwrite/26595652#26595652


i set the filename this way:

endpoint.setFileName("${file:name.noext}-${property.CamelSplitIndex}.txt");




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-split-to-files-and-add-number-to-output-file-names-not-overwrite-tp5758116p5758198.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to split to files and add number to output file names (not overwrite)

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yes you can control the file name to use for writing the file. See
more details at
http://camel.apache.org/file2
http://camel.apache.org/file-language.html

On Mon, Oct 27, 2014 at 6:12 PM, dermoritz <ta...@hotmail.com> wrote:
> I have a route that splits large files into smaller ones. All split files
> should be written to same directory. The default behavior of file endpoint
> (producer) seem to overwrite always.
> Is there an easy way to let the file producer do a simple rename by adding a
> counter to file name? Like in OS if you do copy/paste on a file and OS does
> auto rename by adding (copy-1...).
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-split-to-files-and-add-number-to-output-file-names-not-overwrite-tp5758116.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/