#!/bin/csh # To save a copy of this script select 'save as' in your browser and save # the file as 'less-lang.csh' in the directory/folder of your choice # Copyright 2002, Bill Caloccia, All Rights Reserved # $Id: less-lang.csh.txt,v 1.6 2002/03/04 01:30:35 root Exp root $ # Original at: http://wormtown.team.net/iPod/less-lang.csh.txt # Documentation on using this script follows, and is printed out # each time it is run. cat << END NAME less-lang.csh - the 'installer smaller' script This will identify and prepare for deletion non-English language information in OS X and Applications, and some other useless stuff from a typical Mac OS X install SYNOPSIS less-lang.csh searches mounted disks for non-english language files (*.lproj), mostly in the 'normal' system directories/folders (System/Library, Library, Applications) on mounted Volumes/disks. It is an interactive script, asking which Volumes/disks to search, as well as which 'optional' (non-language) components to remove. Why this script? My PowerBook is running out of space, and my iPod, which is set-up as a diagnostic tool, has precious little space, so if I can save 250+ MB (25%) of an OS X install, that makes for 50 more songs on the iPod, or ~250 images from my digital camera on the PowerBook. Typical install of OS X (10.1.3), without additional languages specified, starts at about 1 GB, about 25% of which can be deleted. Size after Install 10.1 install, no languages 956,528 KB 10/19/2001 Security upate 963,288 KB Installer Update 1.0 965,552 KB Combined 10.1.3 1,005,000 KB DVD 3.01, iTunes 2.03, Java 1.31 update 1 1,022,156 KB After running this script, the size of the install is reduced by ~260 MB to 759,036 KB. You will be asked a number of yes or no questions to determine what you would like to delete. Answering 'y' is 'yes' anything else is a no. Then this script will produce a file with the delete commands in it, you should reivew it before executing it, to make sure you are not deleting someting you desire to keep. OPTIONS none. ENVIRONMENT Mac OS X only. AUTHOR Bill Caloccia, February 2002 http://www.caloccia.net/wpc/ Copyright 2002, Bill Caloccia, All Rights Reserved Original at: http://wormtown.team.net/iPod/less-lang.csh.txt END if ($user != "root") then cat << END WARNING: you must execute this script, as well as the script it creates as an Authenticated Administrative user (e.g. root). You may execute it with 'sudo'. END exit endif # delete previous temp output files /bin/rm -f /tmp/delete-lang*.csh # get mounted volumes that look like physical disks # foreach disk ( / `df -k | grep Volumes | \ # only want mounted volumes # egrep 'disk[0-9][0-9]*s[0-9]' | \ # disk images don't have slice (partition) numbers # sed 's/^[^V]*Volumes/\/Volumes/' | \ # extract path at end of line # sed 's/ /?/g' ` ) # deal with spaces in volume names foreach disk ( / `df -k | grep Volumes | egrep 'disk[0-9][0-9]*s[0-9]' | sed 's/^[^V]*Volumes/\/Volumes/' | sed 's/ /?/g' ` ) if ( -d "$disk" ) then # check to see if it is a directory/exists echo "Do you want to evaluate Volume $disk ? (y|x) " set answer=$< if ( $answer != "y" ) then continue endif cd "$disk" # change dir to disk set d="$disk:t" # get volume name set OUT="/tmp/delete-lang-$d.csh" # set name of temporary out file / script (one per volume) # everything output to $OUT file is a tcsh command, set up file cat << REALEND >! "$OUT" #\!/bin/csh if ($user != "root") then cat << END WARNING: you must execute this script, as well as the script it creates as an Authenticated Administrative user (e.g. root). You may execute it with sudo $0 END exit endif cd "$disk" df -k . set before=(`df -k . | tail -1`) REALEND set nonomatch set jf=(System/Library/Fonts/*.otf) unset nonomatch if ($#jf > 1) then echo "Delete Japanese fonts (62MB)? (y|x) " set answer=$< if ( $answer == "y" ) then cat << END >> "$OUT" echo "deleting Japanese/Asian fonts in System folder (~62MB)" /bin/rm -f System/Library/Fonts/*.otf df -k . | tail -1 END endif endif if (-d 'Library/Desktop Pictures' ) then echo "Delete Desktop images except Aqua* (15MB)? (y|x) " set answer=$< if ( $answer == "y") then echo 'echo "deleting huge desktop images (15MB - except solids and default Aqua*)"' >> "$OUT" find 'Library/Desktop Pictures' -name '*.jpg' -print | grep -v Aqua | \ sed 's/^[^$]*$/\/bin\/rm -rf "&"/' >> "$OUT" echo 'df -k . | tail -1' >> "$OUT" endif endif if ( -d 'System/Library/Screen Savers' ) then echo "Delete Screen Saver Slide Shows (24MB)? (y|x) " set answer=$< if ( $answer == "y") then echo 'echo "deleting huge screen saver slide shows (24MB )"' >> "$OUT" find 'System/Library/Screen Savers' -name '*.slideSaver' -print | \ sed 's/^[^$]*$/\/bin\/rm -rf "&"/' >> "$OUT" echo 'df -k . | tail -1' >> "$OUT" endif endif if ( -e Library/WebServer/Documents/index.html.en ) then echo "Delete non-english apache 'index.html' files (120KB)? (y|x) " set answer=$< if ( $answer == "y") then if (! -e Library/WebServer/Documents/index.html ) then if ( -e Library/WebServer/Documents/index.html.en ) then cat << END >> "$OUT" echo "deleting non-english index.html files in Apache web server (120KB)" mv Library/WebServer/Documents/index.html{.en,} /bin/rm Library/WebServer/Documents/index.html.* df -k . | tail -1 END endif endif endif endif foreach printer ( hp Canon EPSON ) if (-d Library/Printers/$printer ) then set kb=`du -sk Library/Printers/$printer` echo "Delete All support for $printer printers ($kb[1] KB)? (y|x) " set answer=$< if ( $answer == "y") then cat << END >> "$OUT" echo "deleting support for $printer printers ($kb[1] KB) " /bin/rm -rf Library/Printers/$printer df -k . | tail -1 END endif endif end #find $Dirs2LookIn -name '*.lproj' | \ # find all the language files in 'usual' dirs # egrep -vi '(English|en\.|en_)' | \ # remove the english ones # sed 's/^[^$]*$/\/bin\/rm -rf "&"/' # quotate the paths make /bin/rm set Dirs2LookIn foreach d2li ( System Library Applications Local ) if ( -d $d2li ) then set Dirs2LookIn=( $d2li $Dirs2LookIn ) endif end if ( $#Dirs2LookIn ) then foreach dir ( $Dirs2LookIn ) echo echo "deleting non-english '*.lproj' text files in $disk/$dir" >> "$OUT" find $dir -name '*.lproj' | \ egrep -vi '(English|en\.|en_)' | \ sed 's/^[^$]*$/\/bin\/rm -rf "&"/' >> "$OUT" echo 'df -k . | tail -1' >> "$OUT" end endif # wrap-up script set wc =(` grep bin.rm "$OUT" | wc -l`) # how many lines are in the output script if ( $wc[1] == 0 ) then # more than the header we wrote? echo "No Files identified to be deleted on $disk." /bin/rm -f "$OUT" else # yes, more than the header we wrote, output info for user echo "Approx. $wc[1] files identified to be deleted on ${disk}" echo " review and then execute "$OUT"" (echo 'echo "df -k . " ; set after=(`df -k . | tail -1`) ; echo -n "kilobytes deleted " ; echo "$after[3] $before[3] - p" | dc' ) >> "$OUT" chmod 775 "$OUT" endif else # failed check to see if it is a disk echo "Unable to process directory '"$disk"' (maybe has a space in it ?)" endif # check to see if it is a disk end # foreach disk chmod 755 /tmp/delete-lang*.csh # end of program exit # change log # $Log: less-lang.csh.txt,v $ # Revision 1.6 2002/03/04 01:30:35 root # quotated path in file header. #