find latest subfolder in folder , open finder with latest folder

Hello All,

(Im musicman a newbe :slight_smile: )

i want to create a applescript that open’s the latest subfolder from a folder.

info:

  1. Root folder /Users/mamekedi/MyMusic/

  2. Subfolders:

MP3-001
MP3-002
MP3-003
MP3-004
MP3-005

So i want the apple script to check what’s the last folder in folder /Users/mamekedi/MyMusic/ … (MP3-005)
and open it in finder.

So far i have a script that is telling me the folder-names in folder /Users/mamekedi/MyMusic/

Begin Script

tell application “Finder”

get name of folders of folder ("/Users/yucelcetin/marty/" as POSIX file)

end tell

End Script

Results:

{“MP3-001”, “MP3-002”, “MP3-003”, “fMP3-004”, “fMP3-005”}

After that i want to put the last folder in a variable, can you help me with this to

Best Regards
Musicman

Hi,

try this


tell application "Finder" to open last folder of folder "MyMusic" of home

Hello Stefan,

is it so simple … thank you very much it’s working

normally i’m working with linux (shell script) i would use something like:

ls -d */ | tail -1| awk ‘{print substr($0,0,7)}’

Thx Again