Jump to content

[SOLVED] Write current Finder path to a text file

Recommended Posts

I was trying to log the path of the current working directory of Finder window to a text file in Dropbox,  the AppleScript used has no problem but when used in Alfred it gives me the empty log file.


Workflow: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/aa Last Working Directory.alfredworkflow?raw=true


Used AppleScript:

tell application "Finder"
    if exists Finder window 1 then
        set currentDir to target of Finder window 1 as alias
        set currentDir to desktop as alias
    end if
end tell
log POSIX path of currentDir


Error log from debugging:


[2018-11-20 11:24:03][ERROR: action.script] /Users/poudel/Dropbox/Research/zz_LastWD/



How to write the current path of Finder along with date in a text file using Alfred?

Edited by Bhishan
Link to comment

log POSIX path of currentDir sends the path to STDERR, i.e. Alfred's debugger, not to the next action.

Use return POSIX path of currentDir to write the path to STDOUT instead, which will be sent to the next action.

It isn't working in the shell, either. It just looks like it because both STDOUT and STDERR are written to the terminal. If you try to redirect the output to a file with > /path/to/file, you'll see it doesn't work.

Link to comment

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