How to get the latest downloaded file name with applescript programatically?

后端 未结 2 1023
难免孤独
难免孤独 2021-01-16 12:17

I need to get the file name programatically on Mac, am using Selenium to download the file and from downloads folder i need to pick the same file to install programatically,

相关标签:
2条回答
  • 2021-01-16 12:44

    This will give you the latest file (sorted by creation date) of your downloads folder:

    tell application "Finder"
        set latestFile to item 1 of (sort (get files of (path to downloads folder)) by creation date) as alias
        set fileName to latestFile's name
    end tell
    
    0 讨论(0)
  • 2021-01-16 12:54

    Yes Mavericks does open the oldest, but this seams to work by specifying the last item.

    tell application "Finder" set latestFile to last item of (sort (get files of (path to downloads folder)) by creation date) as alias set fileName to latestFile's name end tell

    0 讨论(0)
提交回复
热议问题