« [choose folder] フォルダを選ぶ | トップページ | [OSAX]AppleScript Toolbox »

[Folder]フォルダの基本

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

###フォルダの名前
set strFolderName to "新しく作ったフォルダ" as text

###フォルダを作る場所はデスクトップ
tell application "Finder"
set aliasDefaultLocation to path to desktop folder from user domain as alias
end tell

####フォルダを作る
tell application "Finder"
###同名のフォルダがあるか?をチェック
set boolFolderChk to (exists of (folder strFolderName of folder aliasDefaultLocation)) as boolean
###同名のフォルダがなければ作る
if boolFolderChk is false then
make new folder at aliasDefaultLocation with properties {name:strFolderName}
else
log "フォルダはすでにありました"
end if
end tell

####コメントを入れる
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set comment to "コメントテキスト 検索に便利 このフォルダは削除しても大丈夫です"
end tell
end tell


####ラベル(タグ)をつける
(*
0が ラベル無し
1-7までがデフォルト
*)
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set label index to 1
end tell
end tell


####ロックする
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set locked to true
end tell
end tell


####ロックを解除する
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set locked to false
end tell
end tell


####アクセス権をへんこうする
(*
read write
read only
none
グループは
staff
admin 等『自分』が所属しているグループのみ設定可能
ディレクトリサービスで『GroupMembersip』に自分がのUIDが設定されている事
例:
*)
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set owner privileges to read write
set group privileges to read write
set everyones privileges to read write

set group to "staff"
end tell
end tell


####フォルダの変更日を変更する
####2日前の日付時間
set strDateAndTime to ((current date) - (2 * days)) as date
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set modification date to strDateAndTime
end tell
end tell



####デスクトップの場所
(*
100,100 は左上起点の座標
*)
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
tell folder aliasFolderPath
set desktop position to {100, 100}
end tell
end tell



####『それ』がフォルダか?どうか?
tell application "Finder"
set aliasFolderPath to folder strFolderName of folder aliasDefaultLocation as alias
end tell
###info for Finder外での処理
set objInfo to info for aliasFolderPath
if (folder of objInfo) is true then
log "それはフォルダです"
else
log "それはフォルダ以外です"
end if

|

« [choose folder] フォルダを選ぶ | トップページ | [OSAX]AppleScript Toolbox »

AppleScript Folder」カテゴリの記事