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

后端 未结 2 1022
难免孤独
难免孤独 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
    

提交回复
热议问题