Hi You can use the move option on the Camel file consumer, and then use a bean to calculate the file name. http://camel.apache.org/file2
move=bean:myFileCalculatorBean <bean id="myFileCalculatorBean" class=... And in the bean has a single method public String calculateFileName(@Header(Exchange.FILE_NAME) String existingName) { // check if the file exists, and if so, then do your - number trick to find a "free" name ... } On Thu, May 16, 2013 at 5:04 PM, Peter Hilton <pedro+ca...@lunatech.com> wrote: > On 16 May 2013, at 12:23, Peter Hilton <pedro+ca...@lunatech.com> wrote: >> I’m using Camel to process files, and need to save a copy of each incoming >> file to an 'archive' directory. In addition, if another file arrives with >> the same name as an earlier file, I must add this to the archive with a >> different file name and not overwrite an existing archive file. > > I'm currently hoping to do it like this: > > wireTap("file:///archive?fileName=${date:now:yyyy/DDD}/${file:name}", > archiveFileNameProcessor) > > … where archiveFileNameProcessor is a Processor that modifies the file name > (to avoid overwriting existing files). > > How can I parse the URL in my processor to get today’s path, e.g. > archive/2013/136? The processor to check this directory for existing files, > in order to calculate the next file name in the sequence, for duplicate input > file names. > > Peter > -- Claus Ibsen ----------------- www.camelone.org: The open source integration conference. Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen