[OS X TeX] Trashing synctex.gz file

Herbert Schulz herbs at wideopenwest.com
Wed Aug 5 22:53:42 CEST 2009

On Aug 5, 2009, at 1:55 PM, Josep Maria Font wrote:

> Hi,
> I want that when I choose menu item "Trash AUX files", or its  
> keyboard shortcut cmd-ctrl-A, the synchronization file  
> "jobname.synctex.gz" is also trashed along with .aux, etc. I tried  
> to add the extension to the standard list by following TeXShop  
> Help's advice, i.e., in the Terminal I wrote:
> defaults write TeXShop OtherTrashExtensions -array-add "synctex.gz"
> but this seems to have no effect. Any ideas ?
> JMaF


You might try adding just synctex alone to the list.

Actually I use a macro that I got quite a long time ago. I like it  
because the source window doesn't have to be active (I can use it with  
the Preview or Console active) to get the job done. Adding synctex to  
the list there worked nicely. You may need to fix up broken lines in  
the email or copy and paste from the attached file.


--Applescript direct

property extensions_to_delete : {"acn", "acr", "alg", "aux", "bak",  
"blg", "brf", "dep", "dvi", "ent", "fdb_latexmk", "glg", "gls", "fff",  
"glo", "idv", "idx", "ilg", "ind", "ist", "lg", "loa", "lof", "log",  
"lot", "mtc", "mlf", "nav", "out", "pdfsync", "ps", "snm", "synctex",  
"toc", "tmp", "ttt", "tui", "tuo", "wrm", "xref", "4ct", "4tc"}

property delete_files_only_with_same_name : true
-- If your file is document.tex, setting this true will delete only  
document.aux, document.log, etc., but NOT otherdoc.aux, otherdoc.log,  
-- Otherwise, ALL files with the extensions_to_delete will be deleted.

-- Clean Up By Will Robertson 8/17/2004
-- Fixed For Leopard By Dick Koch 12/11/2007

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 & ".")
			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
		set actualname to the name of this_file
		set actualextension to do shell script "echo " & the quoted form of  
actualname & " | cut -f 2 -d '.'"
		--	if (the name extension of this_file is in extensions_to_delete)  
		if (actualextension 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


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CleanUpFiles.txt
URL: <http://tug.org/pipermail/macostex-archives/attachments/20090805/c4097bfc/attachment.txt>
-------------- next part --------------

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)

More information about the macostex-archives mailing list