I can not take credit for the following script I found on this website but it works well if using the “choose folder” located on the first line. I have a folder on the desktop called Backup_Files which is the only folder I want the script to give me information on. By changing the choose folder to Backup_Files the script cannot find the file. Any suggestions are welcome.
set folSize to convertByteSize from (size of (info for (choose folder)))
if word 2 of folSize is “TB” or word 2 of folSize is “GB” then
display dialog "Your Folder size is… " & folSize & “…You can not burn this folder to a CD.”
return
end if
if word 1 of folSize is less than or equal to 650 and word 2 of folSize is “MB” then
display dialog "Your Folder size… " & folSize & “…You may burn this folder to a CD.”
end if
– Conversion table by Nigel Garvey
to convertByteSize from byteSize
if byteSize is greater than or equal to 1.099511627776E+12 then – Terabytes (2 ^ 40)
((byteSize / 1.099511627776E+12 div 0.01 / 100.0) as string) & " TB"
else if byteSize is greater than or equal to 1.073741824E+9 then – Gigabytes (2 ^ 30)
((byteSize / 1.073741824E+9 div 0.01 / 100.0) as string) & " GB"
else if byteSize is greater than or equal to 1048576 then – Megabytes (2 ^ 20)
((byteSize / 1048576 div 0.01 / 100.0) as string) & " MB"
else if byteSize is greater than or equal to 1024 then – Kilobytes (2 ^ 10)
((byteSize div 1024) as string) & " K"
else
(byteSize as string) & " bytes"
end if
end convertByteSize
Have you considered a droplet? Since your folders are on the desktops of your laptops, they are easily accessed and dropped. Nigel’s swell code even calculted the used space on my hard drive. I cleaned up the dialog presentation too.
on open DroppedFolder
set folSize to convertByteSize from (size of (info for (DroppedFolder)))
if word 2 of folSize is "TB" or word 2 of folSize is "GB" then
display dialog "Your Folder size is: " & folSize & return & "You can not burn this folder to a CD."
return
end if
if word 1 of folSize is less than or equal to 650 and word 2 of folSize is "MB" then
display dialog "Your Folder size is: " & folSize & return & "You may burn this folder to a CD."
end if
end open
-- Conversion table by Nigel Garvey
to convertByteSize from byteSize
if byteSize is greater than or equal to 1.099511627776E+12 then -- Terabytes (2 ^ 40)
((byteSize / 1.099511627776E+12 div 0.01 / 100.0) as string) & " TB"
else if byteSize is greater than or equal to 1.073741824E+9 then -- Gigabytes (2 ^ 30)
((byteSize / 1.073741824E+9 div 0.01 / 100.0) as string) & " GB"
else if byteSize is greater than or equal to 1048576 then -- Megabytes (2 ^ 20)
((byteSize / 1048576 div 0.01 / 100.0) as string) & " MB"
else if byteSize is greater than or equal to 1024 then -- Kilobytes (2 ^ 10)
((byteSize div 1024) as string) & " K"
else
(byteSize as string) & " bytes"
end if
end convertByteSize
Save that as an application and drop any folder.
Or if the folder will always be the same name, on the desktop of any volume (this is what you requested), then
set PathPrefix to (path to desktop as string)--get the path to the desktop
set FolderPath to (PathPrefix & "Backup_Files:") as string--complete the path with folder
tell application "Finder"
set SizeOf to size of (info for alias FolderPath)--alias reference yields info for, get size of
end tell
set folSize to convertByteSize from SizeOf--Here's where your script begins
if word 2 of folSize is "TB" or word 2 of folSize is "GB" then
display dialog "Your Folder size is: " & folSize & return & "You can not burn this folder to a CD."
return
end if
if word 1 of folSize is less than or equal to 650 and word 2 of folSize is "MB" then
display dialog "Your Folder size is: " & folSize & return & "You may burn this folder to a CD."
end if
-- Conversion table by Nigel Garvey
to convertByteSize from byteSize
if byteSize is greater than or equal to 1.099511627776E+12 then -- Terabytes (2 ^ 40)
((byteSize / 1.099511627776E+12 div 0.01 / 100.0) as string) & " TB"
else if byteSize is greater than or equal to 1.073741824E+9 then -- Gigabytes (2 ^ 30)
((byteSize / 1.073741824E+9 div 0.01 / 100.0) as string) & " GB"
else if byteSize is greater than or equal to 1048576 then -- Megabytes (2 ^ 20)
((byteSize / 1048576 div 0.01 / 100.0) as string) & " MB"
else if byteSize is greater than or equal to 1024 then -- Kilobytes (2 ^ 10)
((byteSize div 1024) as string) & " K"
else
(byteSize as string) & " bytes"
end if
end convertByteSize