Applescript: Get filenames in folder without extension

前端 未结 8 1826
忘掉有多难
忘掉有多难 2020-12-11 03:36

I can get the names of all files in a folder by doing this:

tell application \"Finder\"
    set myFiles to name of every file of somePath
end tell

8条回答
  •  无人及你
    2020-12-11 04:08

    From http://www.macosxautomation.com/applescript/sbrt/index.html :

    on remove_extension(this_name)
      if this_name contains "." then
        set this_name to ¬
        (the reverse of every character of this_name) as string
        set x to the offset of "." in this_name
        set this_name to (text (x + 1) thru -1 of this_name)
        set this_name to (the reverse of every character of this_name) as string
      end if
      return this_name
    end remove_extension
    

提交回复
热议问题