6

Using Launchbar, I'd like to be able to do the following:

Navigate around by normal means in Launchbar > Once I'm in desired folder, I'd like to be able to run a command/action that asks me to enter a filename and then the command proceeds to ´touch´ (filename) in that directory.

How can this be achieved, any existing solutions?

2
  • You need to be clearer. What file type you want to create?
    – Ruskes
    Sep 14, 2013 at 14:18
  • @Buscar웃 I want to create a blank new file a la touch blankfile. Typical use would be e.g. when developing websites and you quickly need to touch/create new files. (I'm thinking that it would also be nice if one could name the new file when creating it, via LaunchBar's text input field – but that's not crucial.)
    – Henrik
    Sep 16, 2013 at 1:07

2 Answers 2

7
+300

This can be done by using the "New Text Document Here" action

Select folder -> tab -> start typing "New" -> select "New Text Document Here" -> type name -> enter.

If you're looking for a more complete solution that can create any type of file (including ones without the .txt extension that the New Text Document action forces) try this Applescript. Just put it in a file named New File.applescript in the ~/Library/Application Support/LaunchBar/Actions/ directory:

on handle_string(dir)
    display dialog "Enter filename:" default answer ""
    set fname to text returned of result
    set fullpath to dir & fname
    try
        do shell script "touch '" & fullpath & "'"
        open location "x-launchbar:select?file=" & fullpath
    on error errMsg
        display dialog "Error: " & errMsg
        open location "x-launchbar:hide"
    end try
end handle_string

It'll touch the file, then select it in LaunchBar upon completion (you can comment out the line that does that by adding -- to the beginning of the line or just removing it).

2
  • Copied as it is, I couldn't get this working on OS X 10.9.5, LB 6.1.6. I had to change line 4 to set full_path to dir & "/" & file_name and line 6 to do shell script "touch " & full_path.
    – user36018
    Dec 31, 2014 at 16:33
  • Works as is on OS X 10.10.1 and LB 6.1.6. Jan 9, 2015 at 20:41
0

A custom script as in Justin's answer is the way to go if you need this to be Terminal-free, but if not I'd do it this way:

  1. Select folder via LaunchBar
  2. cmd-T (open Terminal there)
  3. Type "touch whateverfile", return
  4. cmd-W (close Terminal window)
  5. Invoke LaunchBar, cmd-R, return (to get back to the app you were in)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .