Jump to content

Is there a workflow can reveal a opened file in finder


Recommended Posts

Posted

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.

Posted
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?

Posted (edited)
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
Posted
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.

Posted
27 minutes ago, JJJJ said:

It doesn't actually have to be for all kind of files.

 

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

Posted
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.

Posted (edited)
4 minutes ago, JJJJ said:

I mentioned  office files

 

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

Edited by deanishe
Posted (edited)
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
Posted

At the end of this thread there’s an example of trying to target multiple PDF apps (Skim, Preview and Devonthink) with a single Applescript - it’s doable but requires a lot of testing and customizing - unfortunately Applescript grammar isn’t standard even for these most basic tasks.

 

 

Posted
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.

Posted
Just now, JJJJ said:

I know there are many others

 

Pages and pals would work, but LibreOffice, for example, has zero AppleScript support.

Posted

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.

Posted
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.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...