Project abbreviation in Shortcuts?

I have a longer shortcut that asks me for project start/end date and other information, that I run to populate Finder, OmniFocus, Obsidian etc with the essential project information needed.

For files I use project abbreviation and I have long thought to have it done in Shortcuts. For example it already asks me to input the name of the project. So if I write ‘My Next Big Film’ I would want it to automatically generate the abbreviation MNBF.

Would this be possible?

I have Drafts and Text Case that I think would be possible contributors. So far, I’ve made a flow in Text Case that 1) capitalizes and 2) strips whitespace. I can’t, however, get rid of the other letters.

Thanks,
Thomas

Does this work for you?

https://www.icloud.com/shortcuts/195e5254e7b24e90a2e24b0d533f084a

2 Likes

Yes! Thank you! I did try some regex and thought it could be solved with it, but I don’t have the understanding of the syntax yet.

1 Like

A few thoughts on some cases that may occur, but were potentially not covered in your original requirements.

Symbols

If you have projects with symbols in them, e.g. X-Men: Days of Future Past, then the shortcut @gluebyte provided will produce results like X-M:DOFP. This would match your original requirements, but might not be what you want/expect. Furthermore such titles can cause issues if for example you were sharing file names or folders containing these characters with users on Windows. On Windows, a colon is a reserved file name character used in (local and network) drive mappings.

If those additional symbols are undesired, you can change \B.|\s to \B.|\s|\W in the regular expression to strip them out - the above example would become XMDOFP.

Multi-Digit Numbers

If you then consider 2+ digit numbers in titles - e.g. 2001: A Space Odyssey, the numbers get truncated. For the example, this produces 2ASO. I can envisage scenarios where this could be problematic where a series of something enters into two digits or you are working with dates in the same millennia and they are the only parts in the title changing.

If you want to retain full numbers, you could further change the regular expression to \B[a-zA-Z]|\s|\W. The example would then become 2001ASO.

Hopefully, this deeper consideration of requirements and potential revisions is useful. There may well be further cases and edge cases to consider.

2 Likes

Well spotted that these issues may arise! I’m going with your latter suggestion for now and will see how that works :slight_smile: Thanks!

I don’t come here to answer questions. I just come to verify my assumption that @sylumer has already answered or at least covered the remaining corner cases :slight_smile:

Thank you, @sylumer :heart: