We've finished our move from .Mac to our very own domain name: http://www.brettgrossphotography.com/ .

Woo hoo!




Project Size Estimator

Current version: v3 09
Built on: Aperture 1.5.3
This AppleScript operates on one or more Projects.


This script allows a user to select one or more Aperture Projects and then it does some Script Magic© where it will estimate the size of the Project if it is exported with all Masters. It'll give its results in a new TextEdit window because you can display the info in a fixed-width font.

Download




-- -----------------------------------------------------------------------------------------------
--
Forked from v1 04 on 2007-05-15 to incorporate Steve's wicked cool shell script
--
grep -h -A 1 -R --include='*.apfile' fileSize . | awk -F '[<>]' '/integer/ { sum += $3} END {print sum }'

--
-----------------------------------------------------------------------------------------------
property steveOpen : " grep -h -A 1 -R --include='*.apfile' fileSize "
property steveClose : " | awk -F '[<>]' '/integer/ { sum += $3} END {print sum }' "

--
-----------------------------------------------------------------------------------------------
--
p_versCruft is an approximation of all of the files associated with every .apversion file such as previews, thumbnails, etc
--
feel free to adjust this size up or down to suit your configuration.
--
0.27 works pretty well for me
property p_versCruft : 0.27


--
-----------------------------------------------------------------------------------------------
global g_libPath


--
-----------------------------------------------------------------------------------------------
on run
my getLibPath()

set retCD to "Projects that will fit on a single CD (650MB)"
set retDVD to "Projects that will fit on a single-layer DVD (4500MB)"
set retDLDVD to "Projects that will fit on a dual-layer DVD (9000MB)"
set retBig to "Projects too big for common optical media"
set retErr to "Errors processing the following projects"

--
set projPaths to my findByName("*.approject", g_libPath)

--
----------------------------------------------------------- Get the names of all Projects
tell application "Aperture"

set projList to {}
set theProjs to projects
repeat with curProj in theProjs
set end of projList to name of curProj
end repeat
log projList

end tell

--
----------------------------------------------------------- Choose Project(s) to estimate
set theOut to choose from list projList with prompt "Choose a Project to estimate:" default items {"2007 Misc"} with multiple selections allowed

set theRet to ""
set grandTotal to 0

repeat with curName in theOut
try
set projSize to 0

set projName to (contents of curName)

set padLen to (35 - (length of projName))
set thePadding to " "
repeat padLen times
set thePadding to thePadding & space
end repeat

--
set theRet to theRet & projName & thePadding

set projPath to (paragraph 1 of (my findByName((projName & ".approject"), g_libPath)))

set theScript to steveOpen & (quoted form of projPath) & steveClose
set masterSize to do shell script theScript

set projSize to projSize + (masterSize / 1024 / 1024)

--
--------------------------------------------------------------------------------
--
apversions
--
include apversion file
--
include previews
--
include thumbnails
--
set numFound to (count of paragraphs of (my findByName("*.apversion", projPath)))
set numFound to (my countByName("*.apversion", projPath))
log ("Number of versions: " & numFound)
set tmpSize to (numFound * (p_versCruft))
set projSize to projSize + tmpSize

log projSize
set grandTotal to grandTotal + projSize

--
set theRet to theRet & (projSize as integer) & " MB" & return

if projSize > 9000 then
--
------------------- Too big for a dual-layer DVD
set retBig to retBig & return & tab & projName & thePadding & (projSize as integer) & "MB"


else if projSize > 4500 then
--
------------------- It will fit on a dual-layer DVD
set retDLDVD to retDLDVD & return & tab & projName & thePadding & (projSize as integer) & "MB"

else if projSize > 650 then
--
------------------- It will fit on a single-layer DVD
set retDVD to retDVD & return & tab & projName & thePadding & (projSize as integer) & "MB"

else
--
------------------- It will fit on a CD
set retCD to retCD & return & tab & projName & thePadding & (projSize as integer) & "MB"

end if

--
set theRet to (theRet & " Masters: " & ((masterSize / 1024 / 1024) as integer) & " MB" & return)
on error
set retErr to retErr & return & tab & "Error processing Project: " & projName
end try
end repeat

if ((count of paragraphs of retBig) > 1) then
set theRet to theRet & retBig & return & return
end if

if ((count of paragraphs of retDLDVD) > 1) then
set theRet to theRet & retDLDVD & return & return
end if

if ((count of paragraphs of retDVD) > 1) then
set theRet to theRet & retDVD & return & return
end if

if ((count of paragraphs of retCD) > 1) then
set theRet to theRet & retCD & return & return
end if

if ((count of paragraphs of retErr) > 1) then
set theRet to theRet & retErr & return & return
end if


(*

set theRet to retBig & return & return & retDLDVD & return & return & retDVD & return & return & retCD & return & return & retErr & return & return
*)


set theRet to theRet & return & " -------------------------------- " & return

set theRet to theRet & "Grand total: " & (grandTotal as integer) & " MB" & return

tell application "TextEdit"
make new document

tell document 1
set paragraph 1 to theRet
set font to "Monaco"
end tell
end tell

try
display dialog theRet giving up after 60
end try
end run



--
---------------------------------------------------------------------------------------------------------------------------
on countByName(p_fileName, p_rootPath)
set p_comm to "/usr/bin/find"
set p_script to p_comm & space & quote & p_rootPath & quote & " -name " & quote & p_fileName & quote & " -print | wc -l"

--
log p_script
set theOut to do shell script p_script
return theOut
end countByName




--
---------------------------------------------------------------------------------------------------------------------------
on findByName(p_fileName, p_rootPath)
set p_comm to "/usr/bin/find"
set p_script to p_comm & space & quote & p_rootPath & quote & " -name " & quote & p_fileName & quote & " -print"

--
log p_script
set theOut to do shell script p_script
return theOut
end findByName




--
---------------------------------------------------------------------------------------------------------------------------
on getLibPath()

tell application "System Events" to set p_libPath to value of property list item "LibraryPath" of property list file ((path to preferences as Unicode text) & "com.apple.aperture.plist")

if ((offset of "~" in p_libPath) is not 0) then
--
set p_posix to POSIX file p_libPath

set p_script to "/bin/echo $HOME"
set p_homePath to (do shell script p_script)

set p_offset to offset of "~" in p_libPath
set p_path to text (p_offset + 1) thru -1 of p_libPath

set g_libPath to p_homePath & p_path
log g_libPath

--
set g_libPath to "/Work/brett/Pictures/Aperture Library.aplibrary"
else
set g_libPath to p_libPath
end if

end getLibPath