Jump to content

Is there a workflow can reveal a opened file in finder


Recommended Posts

The following AppleScript will do that (which you can execute via Alfred's Run Script action with Language = "/usr/bin/osascript (AS)").

 

tell application "Microsoft Word"

    set theDoc to front document

    set thePath to (path of theDoc) & ":" & (name of theDoc)

end tell

tell application "Finder"

    activate

    reveal thePath

end tell

 

Bear in mind that this is a Microsoft Word + Finder question, not an Alfred question. Generally, a Word-related forum (or Ask Different) would be a more appropriate place to ask such questions.

Link to post
4 hours ago, deanishe said:

The following AppleScript will do that (which you can execute via Alfred's Run Script action with Language = "/usr/bin/osascript (AS)").

 

tell application "Microsoft Word"

    set theDoc to front document

    set thePath to (path of theDoc) & ":" & (name of theDoc)

end tell

tell application "Finder"

    activate

    reveal thePath

end tell

 

Bear in mind that this is a Microsoft Word + Finder question, not an Alfred question. Generally, a Word-related forum (or Ask Different) would be a more appropriate place to ask such questions.

Can it be done for not only a word file but any kind of file?

Link to post
1 hour ago, JJJJ said:

Can it be done for not only a word file but any kind of file?

 

No. The application in question needs to support AppleScript and applications can have whatever grammar they want. There’s no generic solution to to your question.

Edited by vitor
Link to post
1 hour ago, vitor said:

 

No. The application in question needs to support AppleScript and applications can have whatever grammar they want. There’s no generic solution to to your question.

It doesn't actually have to be for all kind of files. If it could work for office files, pdfs or jpgs-pngs when they are opened in preview.app, it might still be very useful I think.

Link to post
18 minutes ago, deanishe said:

 

To be clear: the kind of file is irrelevant, it's the application that the file is open in that matters.

I understand that, that is why I mentioned  office files and the preview.app specifically.

Link to post
18 hours ago, JJJJ said:

It doesn't actually have to be for all kind of files. If it could work for office files, pdfs or jpgs-pngs when they are opened in preview.app, it might still be very useful I think.

 

Then the file type doesn’t matter. That’s what I’m saying: you can tell an application to reveal a document in the Finder, it doesn’t matter what it is. And since you’re telling the application, you can’t have a generic solution, you’d have to include specific grammar for specific apps.

Edited by vitor
Link to post
4 hours ago, deanishe said:

 

Exactly. You can open MS Office files in lots of applications, which is why I wasn't entirely sure you'd understood.

When I mentioned office files, Microsoft office and apple's iwork apps were in my mind, although I know there are many others.

Link to post

Also, if anyone's considering building a "Reveal in Finder" workflow, I'd very strongly recommend using a model similar to my AppScripts or Safari Assistant workflows.


Provide a built-in and a user script directory, and put application-specific scripts in there. When the workflow's run, it should grab the name/bundle ID of the active application, look for a corresponding script in the script directories and run it if found.


The potential for requests to add support for apps is basically limitless, so you really want to make it easy for users to add support for apps themselves, and to answer any feature requests to support app XYZ with "Sure. Write the necessary script, submit a PR, and I'll add it to the next release."

 

Otherwise, you're going to be dealing with endless support requests, many of which will be impossible to implement.

Link to post
17 hours ago, deanishe said:

The following AppleScript will do that (which you can execute via Alfred's Run Script action with Language = "/usr/bin/osascript (AS)").

 

tell application "Microsoft Word"

    set theDoc to front document

    set thePath to (path of theDoc) & ":" & (name of theDoc)

end tell

tell application "Finder"

    activate

    reveal thePath

end tell

 

Bear in mind that this is a Microsoft Word + Finder question, not an Alfred question. Generally, a Word-related forum (or Ask Different) would be a more appropriate place to ask such questions.

thanks! i real want to reveal all kind of file type which currently be open.

Link to post
  • vitor changed the title to Is there a workflow can reveal a opened file in finder

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...