« [list folder]フォルダの中身 | トップページ | [NSArray]要素色々 »

[size]フォルダのサイズ

#!/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

## application support フォルダ
tell application "Finder"
set aliasApplicationSupportFolder to path to application support folder from user domain
end tell

set strFilePath to POSIX path of aliasApplicationSupportFolder as text

tell application "Finder"
set numInfoSize to size of (get info for strFilePath)
end tell
set strInfoSize to numInfoSize as text
if strInfoSize contains "." then
set numFolderSize to numInfoSize / (1000 ^ 3)
return numFolderSize & " GB"
else if (numInfoSize / (1000 ^ 2)) < 1 then
set numFolderSize to (numInfoSize / (1000)) as text
return numFolderSize & " KB"
else
set numFolderSize to (numInfoSize / (1000 ^ 2)) as text
return numFolderSize & " MB"
end if

この方法では『フォルダ』のサイズのみで、『フォルダに内包されれる』サイズは取得できない
#!/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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
set objFileManager to objMe's NSFileManager's defaultManager()


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

set strFilePath to POSIX path of aliasApplicationSupportFolder as text

set ocidFilePath to objNSString's stringWithString:strFilePath
set ocidAttributesDict to objFileManager's attributesOfItemAtPath:ocidFilePath |error|:(missing value)

log ocidAttributesDict as list

log NSFileSize of ocidAttributesDict as text



#!/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

property numDigit : 0

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

tell application "Finder"
set numFolderSize to size of aliasApplicationSupportFolder as number
end tell


if (numFolderSize as text) contains "E" then
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 strDigit to (item 2 of listFolderSize)
set numDigit to strDigit as number
set numDigit to count characters of (numDigit as text)
set strFolderSize to item 1 of listFolderSize as text
set numFolderSize to strFolderSize as number
else
set strFolderSize to numFolderSize as text
set numFolderSize to strFolderSize as number
end if


if numDigit = 3 then
set numFolderSize to numFolderSize * (100) as number
set strFolderSize to numFolderSize as text
else if numDigit = 2 then
set numFolderSize to numFolderSize * (10) as number
set strFolderSize to numFolderSize as text
else if numDigit = 1 then
set numFolderSize to strFolderSize as number
set strFolderSize to numFolderSize as text
else
set numFolderSize to strFolderSize as number
set strFolderSize to numFolderSize as text
end if



if strFolderSize contains "." then
log "バックアップの容量は、" & numFolderSize & " GBです"

else if numFolderSize > 999999 then
set strFolderSize to (numFolderSize / 1000000) as text
log "バックアップの容量は、" & strFolderSize & " MBです"
else
set strFolderSize to (numFolderSize / 1000) as text
log "バックアップの容量は、" & strFolderSize & " KBです"
end if

|

« [list folder]フォルダの中身 | トップページ | [NSArray]要素色々 »

Folder」カテゴリの記事