Read My Scripts.app (Mountain Lion は AppleScript のルールをどう変更したか)
| 固定リンク
■WWW側(グローバルIPアドレス)を取得する
[IP]定期的にグローバルIPアドレスを調べてメールで知らせる【applescript】[LINK]
[AppleScript]www側のIPアドレスを取得する[LINK]
■ローカル実際のアドレス
↑でも(一度system infoの全てを格納する方法)
↓でも同じ
IPv4 address of (system info)
system infoは非常に便利です。
AppleScript version (text, r/o) : the AppleScript version
AppleScript Studio version (text, r/o) : the AppleScript Studio version
system version (text, r/o) : the system version
short user name (text, r/o) : the current user’s short name
long user name (text, r/o) : the current user’s long name
user ID (integer, r/o) : the current user’s ID
user locale (text, r/o) : the current user’s locale
home directory (alias, r/o) : the current user’s home directory
boot volume (text, r/o) : the boot volume
computer name (text, r/o) : the computer name
host name (text, r/o) : the host name
IPv4 address (text, r/o) : the IPv4 address
primary Ethernet address (text, r/o) : the primary Ethernet address
CPU type (text, r/o) : the CPU type
CPU speed (integer, r/o) : the clock speed of the CPU in MHz
physical memory (integer, r/o) : the amount of physical RAM in MB
Macアドレスも取得出来ますので
管理者の方は色々使えますね。
不可視
可視
両方とも1文字を除いて同じ
do shell script "/Developer/Tools/SetFile -a V "
do shell script "/Developer/Tools/SetFile -a v "
大文字か小文字か
の違いだけですね。
「visibles.zip」をダウンロード[Download]
自分メモ兼
リストの中の『some』を握ります。
MacOS9 的には『 起動時に消去する項目』
OSXのUnix的には 『/tmp』
OSX10.6的には 『/var/folder/XXX/XXXXX/:TemporaryItems』
この中にある物は
起動時に削除されます。
AppleScriptでは
こんな感じで指定できますね。
AppleScriptでの日付の整形方法のヒント
↑このような戻り値になるのは
そんな事になっていますので
今日の日付の変換は英語で行なえます。
と
このようにしておく事で
『ユーザーの環境設定』に左右されないって
事になりますね。
「yyyymmdd.rtf」をダウンロード[Download]
「yyyymmdd.scpt.zip」をダウンロード
[Download]
日時関係のオプションはだいたい
こんな感じ
戻り値は実際に試してみてください。
例えば24時間後を求めるなら
で
60日後
って事なら
「now.scpt.zip」をダウンロード[Download]
日付だけでなく
時間も入れたい場合は
このようになりますね。
「yyyymmdd_hhmmss.rtf」をダウンロード[Download]
「yyyymmdd_hhmmss.scpt.zip」をダウンロード[Download]
で
デスクトップフォルダに『今日の日付』のフォルダ作ったり
今日の日付のファイル名に変更したり
と
色々工夫できますね。
「yyyymmdd__make_folder.scpt.zip」をダウンロード[Download]
「yyyymmdd__make_folder.scpt.rtf」をダウンロード[Download]
ワンポイントで
月番号
と
曜日番号
は
as number
とする事で数値でも表示されます。
でも
do shell script "date '+%Y%m%d_%k%M%S'"
ってしちゃうのが
一番早いね......笑
なんか?気が向いたので
基本のおさらいな意味で
info for
ファイルやフォルダの
情報を取得する時に使います。
私はファイルをリネームする時に
拡張子を取得する時とかに良く使います。
詳細はこちら[LINK]のAppleのページにあります。
name | 項目の名前 | Unicode text |
displayed name | 表示される名前 | Unicode text |
name extension | 項目の名前の拡張子 | Unicode text |
bundle identifier | パッケージバンドルID | Unicode text |
kind | 項目の種類。 | Unicode text |
default application | 項目を開くアプリケーション | alias |
creation date | 項目が作成された日付。 | date |
modification date | 最後に変更された日付 | date |
file type | 項目のファイルタイプ | plain text |
file creator | 項目のクリエータ・タイプ | plain text |
short version | の短いバージョン | plain text |
long version | 長いバージョン | plain text |
size | 項目のサイズ(バイト単位)。 | integer |
alias | エイリアスファイルかどうか。 | boolean |
folder | 項目がフォルダかどうか。 | boolean |
package folder | 項目がパッケージかどうか。 | boolean |
extension hidden | 拡張子がユーザに非表示かどうか。 | boolean |
visible | 項目が可視かどうか。 | boolean |
locked | 項目がロックされているかどうか。 | boolean |
busy status | 項目が現在使用中かどうか。 | boolean |
icon position | デスクトップ上の座標。 | point |
folder window | ウインドウの座標 | bounding rectangle |
戻りの値は
Unicode text :ユニコードテキスト
integer:整数のみ
plain text:これはstringに変更になっています
string:文字列
text:CFUserTextEncodingのデフォルトエンコードのテキスト(日本語 MacOS)
alias:エイリアス ファイルの位置情報(データ)
date:日本語だと平成y年m月d日水曜日 hh:mm:ss
アメリカ表記だと"Wednesday, May d yyyy hh:mm:ss PM", とか
ファイルの情報を取得するサンプル
「InfoFile.rtf」をダウンロード
「InfoFile.applescript.txt」をダウンロード
フォルダの情報を取得するサンプル
「FolderInfo.rtf」をダウンロード
「InfoFolder.applescript.txt」をダウンロード
info for Fileな場合
set FilePass to result as alias
で
FilePassに aliasが格納されていますから
set FileName to name of FilePass
とする事で
FileNameに取得したファイルのファイル名だけ
が格納出来るわけです。
同じように
set FileName to size of FilePass
sizeならファイルサイズが取得できますし
name extension で拡張子を取得する事ができます
info for Folderな場合は
set Folderstr to name of FolderPass
set Folderstr to displayed name of FolderPass
の違いも確認できます。
し
if kind of FolderPass is "フォルダ" then
set str to "フォルダです"
else
set str to "ファイルです"
end if
こんな風に処理の分岐をする事もできますね。
AppleScript 2.1 Help【英語】
AppleScript 2.1 Help【日本語】
application support folder | アプリケーションサポート |
applications folder | アプリケーションフォルダ |
current user folder | 現在ログイン中のユーザフォルダ |
desktop folder | デスクトップ |
desktop pictures folder | デスクトップピクチャ・フォルダ |
documents folder | 書類フォルダ |
favorites folder | よく使う項目フォルダ |
fonts folder | フォント |
help folder | ヘルプフォルダ |
home folder | ホームフォルダ |
keychain folder | キーチェーンフォルダ |
library folder | ライブラリフォルダ |
modem scripts folder | モデムスクリプト |
movies folder | ムービーフォルダ |
music folder | ミュージックフォルダ |
pictures folder | ピクチャフォルダ |
preferences folder | 環境設定 |
printer descriptions folder | プリンタ記述 |
public folder | パブリックフォルダ |
scripting additions folder | スクリプティング機能追加 |
scripts folder | スクリプトフォルダ |
shared documents folder | 共有書類フォルダ |
sites folder | サイトフォルダ |
system folder | システムフォルダ |
trash folder | ゴミ箱 |
users folder | ユーザフォルダ |
utilities folder | ユーティリティフォルダ |
desktop | デスクトップ |
folder action scripts | フォルダアクションスクリプト |
fonts | フォント |
frontmost application | 最前面のアプリケーション |
help | ヘルプフォルダ |
modem scripts | モデムスクリプト |
printer descriptions | プリンタ記述 |
preferences | 環境設定 |
scripting additions | スクリプティング機能追加 |
shared documents | 共有書類フォルダ |
shared libraries | 共有ライブラリ |
startup disk | 起動ディスク |
system preferences | システム環境設定 |
temporary items | 暫定項目 |
trash | ゴミ箱 |
voices | 音声 |
このdomainから
パスを取得する方法知りませんでした...汗
まだまだビギナーです。
と
と
と
の違いを理解できれば
良いですね。
10.6からは
(path to downloads folder)
で
ダウンロードフォルダを指定する事も出来るようになった
Accessibility | AccessibilityCheck | AccessibilityForm | AccessibilityInDesign | AccessibilityPDF | Acrobat | Acrobat Action | Acrobat Annotation | Acrobat AppleScript | Acrobat Layer | Acrobat Plug-ins | Acrobat Portfolios | Acrobat Print | AcrobatBarcode | AcrobatDialog | AcrobatForm | AcrobatJS | AcrobatMenu | AcrobatPDF | AcrobatStamp | AcrobatYouTube | AddressBook | Adobe | Adobe InDesign | AdobeAppleScript | AdobeBridge | AdobeIllustrator | AdobeJSX | aed | Alfresco | Android | AnimationGif | Apple | AppleScript | AppleScriptBasics | AppleScriptCharacter | AppleScriptColor | AppleScriptDroplet | AppleScriptErrorNum | AppleScriptFolder | AppleScriptFontBook | AppleScriptRename | AppleScriptTools | AppleSymbols | Applications | Barcode | Barcode2D | BarcodePostal | BetterHTMLExport | Book | Browser | buzz | Certificates | CharacterEntity | CharacterSets | Colors | Cool Site | CSS | Cutting | DecoMail | DecorationMail | Design | Desktop | Diff | DJ | dmg | DNS | Documents | Download | eBook | Editer | eMail | Envelopes | ExifTool | Facebook | FFmpeg | File System | Fonts | FontsTool | FontsWeb | FOOD | FormPrint | ftp | Gadget | Gif Animation | Google | HexEditor | HTML | info | iPhoto | ISBN | ISO | iTunes | iWork | iWorkNumbers | iWorkNumbersCalendar | iWorkNumbersTimecard | iWorkPages | JavaScript | JeditX | JeditX Regexp | JeditXAppleScript | JIS | jquery | Letterpress | Library | logo | Mac Admin | Mac Archiver | Mac Browser | Mac Browser Plugin | Mac QuickLook | Mac Spotlight | Mac Video | Map | Mobby | Moto | Movies | Music | Network Basic | ntp | OCR | Office | OSX | Pantone | Paper | PDFlib | Permission | Photo | Pictograms | Print | Public | QuickLook | QuickTime | QuickTimeSetting | QuickTimeSound | Real Media | ReName | ResourceFork | ruby | Screen | ScreenCast | Search | Security | SEO | Sharing | SLAResource | Spotlight | Stamp | SWF | Tutorial PSD | TV | Twitter | Typography | Unicode | Utilities | Video | WebFont | Wedding | Windows | WindowsMedia | XML | XMP | XPS | YouTube | YouTube Rss