llityslife Posted August 3, 2019 Posted August 3, 2019 when i open a word file, how to reveal this ducument in finder? thanks!
deanishe Posted August 3, 2019 Posted August 3, 2019 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.
JJJJ Posted August 3, 2019 Posted August 3, 2019 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?
vitor Posted August 3, 2019 Posted August 3, 2019 (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 August 3, 2019 by vitor
JJJJ Posted August 3, 2019 Posted August 3, 2019 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.
deanishe Posted August 3, 2019 Posted August 3, 2019 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. JJJJ 1
JJJJ Posted August 3, 2019 Posted August 3, 2019 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.
deanishe Posted August 3, 2019 Posted August 3, 2019 (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 August 3, 2019 by deanishe
vitor Posted August 3, 2019 Posted August 3, 2019 (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 August 4, 2019 by vitor JJJJ and llityslife 2
dfay Posted August 3, 2019 Posted August 3, 2019 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. llityslife and JJJJ 2
JJJJ Posted August 3, 2019 Posted August 3, 2019 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.
deanishe Posted August 3, 2019 Posted August 3, 2019 Just now, JJJJ said: I know there are many others Pages and pals would work, but LibreOffice, for example, has zero AppleScript support.
deanishe Posted August 3, 2019 Posted August 3, 2019 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. JJJJ, nikivi and llityslife 3
llityslife Posted August 4, 2019 Author Posted August 4, 2019 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now