I am working on a macro which at some point saves or exports the file I am working in. The file often already exists in the save directory.
Is there a way to save and specify replace if file exists, or if not give a small variant equivalent to a version number to the filename?
thanks very much for your time and help
If i understand you, you can check if the file exists, and if so, rename it with a version number.
Then save your new file.
You can keep a variable "version" that keeps increasing the version number, etc.
thank you very much !
I am very sorry: I am still having difficulty writing the macro.
I like your idea of version numbers
If I arrive after exporting at the screen depicted below, what is the next action on my macro.
thanks very much for your time and patience
I’m on vacation so I can’t answer too thoroughly, but I’d imagined it where, rather than renaming the file as you save, you can use the action I posted last week to rename the OLD file, then save your current file with the default name.
I’ll circle back when I’m back in town unless someone else beats me to it.
Thank you very much! I will work on our in the meantime.
Have a nice trip!!!
This is what I was imagining.
Then save your file with it's original name (in this case,
file.pdf). This will let you have a versioned history of changes and you'll never have to worry about overwriting. No need to do anything special with the save dialog. You'll have to set the variable "Version" to 0001 before these actions. I did it at the beginning of the macro and then disabled that
Set Variable “Version” to Text “0001” action.
This may be of interest to some people.
I created a macro on request that increments file versions. If you go back to a previous version and increment that, it will increment the increment.
For example, first round increments:
Test - v.1
Test - v.2
Test - v.3
Then, if you increment Test - v.2:
Test - v.2
Test - v.2.1
Test - v.2.2
Test - v.2.3
It uses the Split Text plugin, as I'm no good with regex. If anyone can improve upon this, please do!
Incremental Save.kmmacros (50 KB)
NB: Some apps (Textedit and Preview for example) do that open-duplicate-in-another-window thing instead of opening a Save As dialog, so you'd need to modify the macro to account for this behaviour.