You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Problems with Applescript "set hidden extension" in a Quick Action

I often need to change the "hide extension" attribute of (downloaded) pdfs so that the extension displays in Finder. I'd written a script which does what I want it to do. It would be quicker and more convenient to have a Quick Action in Finder to do the same thing but I can't seem to get it to work.


Obviously in a Quick Action I don't need to tell Finder to do anything so ignoring that bit, my working script is effectively just creating a list and running "set hidden extension" to false on all the items in it.


set filesToModify to (choose file with multiple selections allowed)
repeat with fileItems in filesToModify
   set extension hidden of fileItems to false
end repeat


Creating a Quick Action with Automator I've tried to keep the same code with essential modifications only. The code below doesn't include the return or end run statements because I know the error happens before those are reached.


on run {input, parameters}
   set filesToModify to input as list
   repeat with fileItems in filesToModify
      set extension hidden of fileItems to false
   end repeat


Creating the list seems to work ("as list" may be redundant). I have checked that after that line it is really a list of aliases of the files selected before the Quick Action is run.


The loop also starts as expected.


The problem seems to be with the "set extension hidden" line which results in a stack overflow. It makes not difference whether one file or multiple files have been selected.


Can anyone tell me what I'm doing wrong?

Posted on Jan 27, 2021 4:42 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 28, 2021 10:11 AM

> Obviously in a Quick Action I don't need to tell Finder to do anything


Actually, you do.


extension hidden is a property of a file that the Finder maintains. Only the Finder can see/set this value.


Off hand, I don't know why the script even compiles, but even the non-QuickAction version of your script throws the same error.


Changing it to:


	tell application "Finder" to set extension hidden of fileItems to false


fixes the issue.

Similar questions

2 replies
Question marked as Top-ranking reply

Jan 28, 2021 10:11 AM in response to gakushaburu

> Obviously in a Quick Action I don't need to tell Finder to do anything


Actually, you do.


extension hidden is a property of a file that the Finder maintains. Only the Finder can see/set this value.


Off hand, I don't know why the script even compiles, but even the non-QuickAction version of your script throws the same error.


Changing it to:


	tell application "Finder" to set extension hidden of fileItems to false


fixes the issue.

Problems with Applescript "set hidden extension" in a Quick Action

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