[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
| 固定リンク
「Folder」カテゴリの記事
- フォルダ内のファイルの情報をHTMLで出力する 少し修正(2024.10.17)
- フォルダ内のファイルを比較 差異があるファイルにはラベルを付与(2024.07.18)
- ファイル名でフォルダを作って、その中に入れる(WEBLOCファイル対応)(2024.06.23)
- フォルダ名で検索 ドロップレット(2024.06.04)
- フォルダのロック解除(2024.05.05)