Renaming files with a higher numerical value (e.g: rename file xxx_004 into xxx_005, xxx_005 into xxx_006 and so on)

HI everyone,

How can I create a workflow that would insert a file that has a numerical value (eg xxx_003.doc) into a folder containing a list of files that are themselves numericaly ordered and that already contains a file called xxx-003.doc? In other words, I would like all the files with higher than xxx_002.doc values to be renamed by one value higher so that my new file xxx_003 does not over-write the existing file:

 

For example, I want to insert a file called xxx_003 into the following list of files:

xxx_001.dox

xxx_002.dox

xxx_003.doc         I want  to insert a new xxx_003.doc file

xxx_004.doc       ->           to become xxx_005.doc

xxx_005.doc       ->           to become xxx_006.doc

xxx_006.doc       -->          to become xxx_007.doc

xxx_007.doc       -->          to become xxx_008.doc

…                         -->           …

Many thanks,

Alexis

 

You could build your filename in a Java snippet or Java edit variable, and check whether the file exists.  If it does, increment a counter and check again until it doesn't

... and in order to check the existence of a given file, you could use the List Files node.