#1 : 02/02-21 16:11 Alex
Posts: 1
|
Hi,
I have files like this: 1.jpg 1_1.jpg 1_2.jpg 2.jpg 2_1.jpg It needs to be: 1_1.jpg 1_2.jpg 1_3.jpg 2_1.jpg 2_2.jpg In other words the filename that has no underscore needs to have _1 added to it Filenames with pre-existed underscores need to have number after underscore incremented by one Any help will be appreciated. Thanks! |
#2 : 02/02-21 22:54 David Lee
Posts: 1125
|
Try a script method with the following code:
match = item.name.match(/(.*_)([0-9]+)$/); if (match) { return match[1] + (match[2]*1 + 1); } else { return item.name + "_1"; } To avoid "collisions", make sure that the filenames in the List are in DESCENDING order - ie higher numbers at the top. (Clicking on the "Filename" header will toggle between ascending and descending order). |