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
    else
        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/

 

**Question**

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

Edited by Bhishan
Link to post

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 post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...