Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
36 views
in Technique[技术] by (71.8m points)

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

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, am using Applescript to do the same. I am stuck in getting the file name in runtime, also my download page url doesnot contain full name of the download file. Pls suggest..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...