[OS X TeX] "Clean up" macro

Will Robertson will at guerilla.net.au
Thu Aug 19 00:49:38 EDT 2004


On 17 Aug 2004, at 12:32 PM, Will Robertson wrote:

> I've got a macro for you guys to test!

In light of possible list troubles, I'd just like to ask if anyone has 
tried out this macro (I've quoted it at the end of this post). Any 
problems? Suggestions?

To install, simply open up the TeXShop macro editor and copy/paste the 
script in.

Cheers,
Will

My "Clean Up" macro:

> --Applescript
>
> -- CUSTOMISE TO YOUR LIKING:
> property extensions_to_delete : {"aux", "bbl", "blg", "brf", "glo", 
> "idx", "ilg", "ind", "loa", "lof", "log", "lot", "mtc", "mlf", "out", 
> "pdfsync", "toc"}
>
> property delete_files_only_with_same_name : false
> -- If your file is document.tex, setting this true will delete only 
> document.aux, document.log, etc., but NOT otherdoc.aux, otherdoc.log, 
> etc.
> -- Otherwise, ALL files with the extensions_to_delete will be deleted.
>
> -- THE SCRIPT:
> tell application "TeXShop"
>
> 	set texpath to alias posix file #TEXPATH# -- gives "/path/to/docu.tex"
>
> 	tell application "Finder"
> 		set texfolder to the container of (texpath as alias)
> 		if delete_files_only_with_same_name then
> 			set texname to the name of (texpath as alias)
> 			set texname to do shell script "echo " & the quoted form of texname 
> & " | cut -f 1 -d '.'"
> 			set texfiles to every file in texfolder whose name contains 
> (texname & ".")
> 		else
> 			set texfiles to every file in texfolder
> 		end if
> 	end tell
> 	
> 	set files_to_delete to {}
> 	set filenames_to_delete to {}
> 	
> 	repeat with this_file in texfiles
> 		if (the name extension of this_file is in extensions_to_delete) then
> 			set the end of files_to_delete to (this_file)
> 			set the end of filenames_to_delete to "    " & (the name of 
> this_file as string) & return
> 		end if
> 	end repeat
> 	
> 	display dialog "Are you sure you want to move the following files to 
> the trash?" & return & filenames_to_delete as string buttons {"Keep", 
> "Trash"} default button "Trash" with icon caution
> 	
> 	if the button returned of the result is "Trash" then
> 		tell application "Finder" to move every item of files_to_delete to 
> the trash
> 	end if
> 	
> end tell

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the MacOSX-TeX mailing list