Apple Script から Finder を使って、いろいろな関数を作ってみた。
on makeDir(args)
set {path_:aPath, dir_name_:aDirName} to ¬
args & {path_:"", dir_name_:""}
tell application "Finder"
set path1 to (aPath & "/" & aDirName) as POSIX file
set isExist to exists of path1
if isExist is false then
set path2 to aPath as POSIX file
make new folder at path2 with properties {name:aDirName}
end if
return (alias path1)'s POSIX path
end tell
end makeDir
on makeCopy(args)
set {from_path_:aFromPath, to_path_:aToPath} to ¬
args & {from_path_:"", to_path_:""}
tell application "Finder"
set path1 to aFromPath as POSIX file
set path2 to aToPath as POSIX file
duplicate path1 to path2 with replacing
return aToPath & my filename({path_:aFromPath, isExt_:true})
end tell
end makeCopy
on getParent(args)
set {path_:aPath} to ¬
args & {path_:""}
tell application "Finder"
set path1 to aPath as POSIX file as alias
set thisFolder to parent of path1
return (alias (thisFolder as text))'s POSIX path
end tell
end getParent
on del(args)
set {path_:aPath} to ¬
args & {path_:""}
tell application "Finder"
set path1 to aPath as POSIX file
delete (path1)
end tell
end del
on openDir(args)
set {path_:aPath} to ¬
args & {path_:""}
tell application "Finder"
set path1 to aPath as POSIX file
open folder path1
end tell
end openDir