Renaming a File if a Another File With the Same Name Exists

Here's a neat variant -- product of me looking at the %CalculateFormat% token last night. You can use that to format the appended "counter":

%CalculateFormat%Local__i%-000% --> MyFile-001
%CalculateFormat%Local__i% (0)% --> MyFile (1)
%CalculateFormat%Local__i% (Copy 00)% --> MyFile (Copy 01)

...and so on.

Move File with Rename if Exists.kmmacros (5.1 KB)

Image

You could change it to use @Tom's final "Try/Catch" method rather than my "test until safe name found", then you'd only have the nastily-long destination calculation in there once.

3 Likes