Friday, October 22, 2021

#1 2021-06-30 03:19:00 am

Registered: 2019-10-23
Posts: 901

Make folder with Finder to have more control of the output

Simple script that use Finder to make a folder more useful with more control.

It include: foldername, seperator, current date, date format, locale, uuid string with digits
Ps. it use POSIX file so we could use POSIX path instead of HFS.


use framework "Foundation"
use scripting additions

set thePath to POSIX path of (path to desktop)
makeFolderWithDate("AppleScript", "-", "yyyy-MM-dd", "sv_SE_POSIX", 5, thePath)

on makeFolderWithDate(folderName, seperator, dateFormat, dateLocale, digitString, thePath)
   set theDate to my createDateString(dateFormat, dateLocale)
   set UUIDString to my createUUIDString(digitString)
   tell application "Finder"
       make new folder at POSIX file thePath with properties {name:(folderName & seperator & theDate & seperator & UUIDString)}
   end tell
end makeFolderWithDate

on createUUIDString(digitString)
   set UUIDString to (current application's NSUUID's UUID())'s UUIDString() as text
   return text 1 thru digitString of UUIDString
end createUUIDString

on createDateString(dateFormat, localeIdentifier)
   set formatter to current application's NSDateFormatter's alloc()'s init()
   formatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:localeIdentifier)
   formatter's setDateFormat:dateFormat
   set folderDate to (formatter's stringFromDate:(current date)) as text
end createDateString

if you are the expert, who will you call if its not your imagination.



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)