Creating a vending service to create a new document in the current directory

so I'm trying to create a service that will be located in the Finder context menu, and which will allow you to create a new document in the current directory.

I do this using Automator: Automator project Sorry, everything is in French ^^

Anyway, here is the AppleScript that I use to retrieve the current working directory:

on run {input, parameters} tell application "Finder" set pwdAlias to insertion location as alias if not (exists folder pwdAlias) then set pwdAlias to (container of pwdAlias) as alias end if end tell set pwd to POSIX path of pwdAlias return pwd end run 

Then I set this value to a variable, and then create a new text document using the variable as the path to the document, and finally I use the Reveal in Finder command to show the created document.

Everything works fine, except the script is always late ! I mean, when I open a new Finder window and select my service, it systematically creates a document in the previous window, as shown below: Selecting Create a new documentThe document is created at the wrong location

But if I try a second time, the document will be created correctly in the expected location: Trying again to create a new documentThis time the document is created properly!

And it is very systematic it happens every time!

Sorry if I'm not very clear, it is not so easy to explain!

Ok, otherwise I run Mountain Lion, and here comes the Automator project: create_new_document

To add a service, simply unzip and place the file in the ~ / Library / Services / folder

Hope to get answers, but I'm afraid this is just an Automator mistake!

+7
source share
3 answers

Try enter image description here

  • Depending on what you want to click .

Install the services selected for: ' folders . or files or folders . in ' Finder.app '

  • Get the first path to the Finder Action window

You can download the β€œGet First Search” window. The action from my blog post is here. The download is at the bottom of the post. The action gets the posix path of the window of the very first crawler. Since you click on the folder in the window. This window will be returned.

  • Set variable value

  • Get the specified text

The next β€œNew Text File” action needs some input. If it fails, the file will not be created. You can leave the text field blank . Just doing the action in place works.

  • New text file

Drag the path variable or whatever you specify in the Where drop-down menu:

you can click the double blue lines at the bottom of the Automator window to switch the list of workflow variables

workflow variable list

Save your service. And try it. (This may take a short time to appear in the context menu.)

+6
source

This open error in 10.7 and 10.8

Use this Workaround

 on run {input, parameters} activate application "System Events" activate application "Finder" tell application "Finder" set pwdAlias to insertion location as alias set pwdAlias to (container of pwdAlias) as alias end tell return POSIX path of pwdAlias end run 
+3
source

to create a new file in one click, you want to use the drop (the button inside the search toolbar, accessible from any search window). After searching the Internet for more than one hour, I finally found THE ULTIMATE LINK:

http://www.screenr.com/cNH and text version: http://blog.themeforest.net/general/amp-up-productivity-with-os-x-finder-droplets/

Welcome.

+1
source

All Articles