"System" Applescripts broken by Catalina?

For many years, I have used a specific Applscript (/Library/Scripts/Finder\ Scripts/Add\ to\ File\ Names.scpt) to add prefixes or suffixes to file names.


After upgrading to Catalina (now 10.15.6), I find it is broken, in way that might be fixable. Now, instead of entering the string I have specified as a suffix or prefix, it enters the word Suffix or Prefix, oddly capitalized, as a suffix, no matter whether I have pressed the prefix button or the suffix button.


Should I copy the script here, or is the filepath enough?



MacBook Pro 13”, macOS 10.15

Posted on Sep 2, 2020 5:03 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 5, 2020 8:45 AM

I have rewritten the old AppleScript that you posted. The replacement script works from the menu extras Script menu, as well as interactively if you choose to run it standalone in that manner. It checks if a folder is selected in the Finder and if true, then prompts you for the prefix/suffix string. Otherwise, it will open a folder chooser, followed by the string prompt. Based on the Prefix, or Suffix button selected, that string will be applied to every filename in the chosen folder.


You copy/paste the following AppleScript code into your open Script Editor, and then save that as AppleScript source. Then by pressing the option key, you Save As… to a script (.scpt) format. In your /Users/yourname/Library/Scripts folder, you create a new folder named Finder Items, and copy your .scpt version of the script into that folder.


When you select Script Editor : Preferences : General, use these settings:


to have this, where I named the script prefix_suffix.scpt:


The first time you use this, Catalina is going to go security in your face. Just click OK to allow the script permissions to do its thing:





Similar questions

15 replies
Question marked as Top-ranking reply

Sep 5, 2020 8:45 AM in response to autnagrag

I have rewritten the old AppleScript that you posted. The replacement script works from the menu extras Script menu, as well as interactively if you choose to run it standalone in that manner. It checks if a folder is selected in the Finder and if true, then prompts you for the prefix/suffix string. Otherwise, it will open a folder chooser, followed by the string prompt. Based on the Prefix, or Suffix button selected, that string will be applied to every filename in the chosen folder.


You copy/paste the following AppleScript code into your open Script Editor, and then save that as AppleScript source. Then by pressing the option key, you Save As… to a script (.scpt) format. In your /Users/yourname/Library/Scripts folder, you create a new folder named Finder Items, and copy your .scpt version of the script into that folder.


When you select Script Editor : Preferences : General, use these settings:


to have this, where I named the script prefix_suffix.scpt:


The first time you use this, Catalina is going to go security in your face. Just click OK to allow the script permissions to do its thing:





Sep 4, 2020 6:12 AM in response to VikingOSX

Apple has reversed the order of the result list returned from the display dialog from what it was when this script was originally written in the early to mid 2000's. Consequently, and as written, the script now assigns the button Prefix, or Suffix name as the string, and not what is entered at the prompt. This is easily fixed and solves the prefix string issue, but the script logic is broken with suffixes as it appends your input string to the extension name, not to the base filename prior to the extension. This renders the filename as an unknown to the operating system.


This script could be eventually modernized to apply a prefix, or suffix to the base filename in less code. Let me see what I can do with the existing code with regard to proper suffix application.


[Update} I now have prefix and suffix strings working correctly on the base filename string, without impacting the extension name. But more testing is needed.

Sep 3, 2020 1:49 AM in response to autnagrag

Neither Catalina, Mojave, High Sierra, nor El Capitan provide a Finder Scripts folder, or the Add to File Names.scpt script in the following path locations:

  1. /Library/Scripts
  2. /Users/yourname/Library/Scripts


This suggests to me that this is something you installed yourself, and/or has propagated via either migration assistant from an older operating system, a Time Machine restore, or years of just upgrades to the operating system.


Click the code <> button in the bottom toolbar here, and after you open the Add to File Names.scpt, select all of the code, and copy/paste it into the the area defined by the <>, enter an extra line after the pasted code, and then click the <> button again. This is the only way you can share code here that will not be a total mess.

Sep 5, 2020 8:21 PM in response to autnagrag

Wow, y’all rock. I live in the northwest now but you can tell from that remark that at one time I lived in the south. I’ve been intensely occupied with work since posting this but I have read your replies and I am grateful and delighted. In a day or two when the anvil has been lifted from my neck, I will investigate further. Thank you for your interest and attention.

Sep 9, 2020 10:35 AM in response to autnagrag

Thank you very much. There were fires, smoke, and a holiday. I did not mean to appear inattentive. The script you are working on is one I used dozens of times a year, but have not needed until last August, under Catalina.


As for your question, yes, exactly right. I would hope that after entering a <string> and hitting "prefix button," I would see the name of the file target.ext changed to stringtarget.ext, and that after entering a <string> and hitting "suffix button," I would see the name of the file target.ext changed to targetstring.ext.

Sep 9, 2020 10:56 AM in response to etresoft

I have compiled the AppleScript, put in a place I'm allowed to put it, changed the System Preferences>Security>Privacy settings as needed. I did not see the dialog predicted, but probably gave the wrong answer a while ago, so I worked around it.


The script works very well, and I thank you, VikingOSX.


Et vous, etresoft, ce que vous m'avez montré marche aussi très bien. Merci, pour tout. Votre app se trouve formidable, je prendrais un moment d'ajouter.

Sep 9, 2020 11:04 AM in response to VikingOSX

I probably will use the Finder's contextual menu, but since you went to the trouble of writing the script, after reviewing its output more closely, I find it renamed all files and folders/directories at the root (perhaps an improper use of that word) level of the target directory. It would be better named items_prefix_suffix.applescript, or present a choice with buttons "files" "folders" "both," or just target files, and be named files_prefix_suffix applescript.

Sep 9, 2020 11:11 AM in response to autnagrag

As tested here, the script determines if you have already selected a folder, or filenames in the Finder when it is run. If so, and it is a folder, then every file in its first level contents gets either the prefix, or suffix treatment. If it is one or more files, then the chosen prefix or suffix is applied to each selected file(s). If there is no Finder selection at all, then it allows you to pick the folder whose first level contents that you want to apply the prefix, or suffix string too.


The Finder Rename : Add Text panel does not apply its changes to sub-folder contents either.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"System" Applescripts broken by Catalina?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.