Creating New Files in Alfred 2

This was just an quick thought of how I could manage this so don’t take this as being something golden but, with Alfred 1.x, there were times that I wished there was an easy way to create a new file in a folder. With Alfred 2, its a little easier to accomplish ­čÖé

Create File Workflow

So, this was the thought and it actually works. The only downside to is that, since it uses AppleScript to repopulate the Alfred input field there is a slight flicker in it when moving through the steps. So, here’s how it works. Create New File is a folder action. I would select a folder in the Alfred file navigation or select a folder as a search result, and move to the actions. There I would select “Create New File”. That would execute a script that would take the selected path and temporarily save it to a plist so it could be passed between the multiple steps a little more cleanly. It would then run an Applescript that would show Alfred, populated with the text “newfile” which is a script file. That script filter would read the path value, and then read the file name input as it was typed and show you a result of “Create New File temp.txt” with the subtext telling you where you would be creating this new file. When you press Enter, this would again run a script that would create the new file for you, and then run an Applescript that would reopen Alfred 2, with the text field populated to the full path to the new file. By giving it a file, its in the file navigator, with that file selected. So then at that point you could open it, email it, or any of the other file actions that you have available in Alfred.

New File Screenshot

If I don’t wipe the value of the path after the file is created, I could also create subsequent files pretty quickly as well because the desired path is already there. So, after the first file is created, you would simply enter in the ‘newfile’ keyword and then the filename and it continue creating files in the previous directory. If you ┬áneeded to change directories, you would go back to the file action and set the new path.

So, what do you guys think of this method? Can you think of an easier way to do this? I’d love to hear some feedback on this.