Page 1 of 1

Increment file name by 1 based on first 8 characters

Posted: Tue Sep 16, 2014 6:23 pm
by MattV
Hi,



I'm trying to rename a file such that each file is incremented by one dependent on the first 8 characters.



ie if I put in 20140101_matt, out comes:

20140101_matt01

20140101_matt02

etc



if I put in 20140102_matt, out comes:

20140102_matt01

20140102_matt02



I'm struggling to get Switch to recognise the [1,8] segment of the filename proper to achieve this.



Any help greatly appreciated!



Thanks

Matt

Increment file name by 1 based on first 8 characters

Posted: Tue Sep 16, 2014 8:27 pm
by gabrielp
I think you should see if there's a better way to do this, but what I would do is keep the increment value in private data somewhere. Then, whenever it encounters your rename, do a replace and use filename proper segment 1-14 (or whatever) and concatenate the version number from private data. Then do another private data write and increment the version number using math in single line text with variables. The leading 0 introduces a problem though.

Increment file name by 1 based on first 8 characters

Posted: Tue Sep 23, 2014 5:58 pm
by MattV
Thanks for the response.



Is there no way to specify the first 8 characters (segment [1-8]) for example to use as the ID?



Thanks

Increment file name by 1 based on first 8 characters

Posted: Tue Sep 23, 2014 6:11 pm
by gabrielp
MattV wrote: Thanks for the response.



Is there no way to specify the first 8 characters (segment [1-8]) for example to use as the ID?



Thanks
Are you asking how to grab the segment itself or are you looking for something else?




Increment file name by 1 based on first 8 characters

Posted: Tue Sep 23, 2014 6:40 pm
by MattV
I'm attempting to add 2 numbers to end of the filename proper using the 'Switch > Counter' parameters in the renaming element.



For example, the following two files would be renamed as such:



20140101_eop -> 20140101_eop01

20140101_eop -> 20140101_eop02



But, a different dated file would reset the counter to 1 again, so that it would be:

20140102_eop -> 20140102_eop01

and not 20140102_eop -> 20140102_eop03



So the segment [1-8] would need to be the ID, so that switch recognises the change.







I hope that makes sense!



Thanks

Matt