« [OSAX]AppleScript Toolbox | トップページ | [size]フォルダのサイズ »

[list 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



###アプリケーションサポートフォルダ
tell application "Finder"
set aliasApplicationSupportFolder to path to application support folder from user domain as alias
end tell


### iPhoneのバックアップフォルダ
tell application "Finder"
set aliasBackupFolder to folder "Backup" of folder "MobileSync" of folder aliasApplicationSupportFolder as alias
end tell

### バックアップフォルダの中身
###ここで『フォルダの中身』を取得しています
tell application "Finder"
set listInSideFolder to (list folder aliasBackupFolder without invisibles) as list
end tell

if listInSideFolder is {} then
return "【情報】iPhoneのバックアップは,このMacにはありません"
end if


#### 順番にフォルダを処理する
repeat with objInSideFolder in listInSideFolder
set strInSideFolder to objInSideFolder as text
tell application "Finder"
set aliasObjInSideFolder to folder strInSideFolder of folder aliasBackupFolder as alias
tell folder aliasObjInSideFolder
--->通常の処理はここで
set strModificationDate to modification date as text
log "バックアップは," & strModificationDate & "に取得した内容です"
end tell
end tell
####フォルダのサイズを取得します
tell application "System Events" to set numFolderSize to size of aliasObjInSideFolder as number
set strFolderSize to numFolderSize as text
set AppleScript's text item delimiters to "E"
set listFolderSize to every text item of strFolderSize
set AppleScript's text item delimiters to ""
set strFolderSize to item 1 of listFolderSize as text
if strFolderSize contains "." then
log "バックアップの容量は、" & strFolderSize & " GBです"
else if numFolderSize > 99999 then
set strFolderSize to (numFolderSize / 100000) as text
log "バックアップの容量は、" & strFolderSize & " MBです"
else
set strFolderSize to (numFolderSize / 1000) as text
log "バックアップの容量は、" & strFolderSize & " KBです"
end if
end repeat


set numCntBackUpFolder to (count of listInSideFolder) as number
if numCntBackUpFolder > 1 then
log "【警告】このMacには," & numCntBackUpFolder & "台分のiPhoneのバックアップがあります"
end if

|

« [OSAX]AppleScript Toolbox | トップページ | [size]フォルダのサイズ »

AppleScript Folder」カテゴリの記事