[OS X TeX] script for deleting all .aux files

Will Robertson will at mecheng.adelaide.edu.au
Wed Jun 2 14:37:19 CEST 2004

On 2 Jun 2004, at 18:39, Frank Mathias Mattes wrote:

> Dear TeX experts,


> does anyone has a apple script (which can be started from TeXShop) 
> which deletes all the accessory files like .aux, in the folder and 
> subfolder ?

I didn't, but you've inspired me.
Assume you're working on the file "document.tex". This script will move 
to the trash all files in the same folder with the pattern document.* 
except for document.tex and document.pdf.
It's a bit clunky, but it works. The TeXShop syntax isn't very good for 
things like this, I find...


ATTACHED: Applescript to delete aux, log files etc from TeXShop:


tell application "Finder"
	set texpath to alias posix file #TEXPATH#
	set texfolder to the container of texpath
	set texname_ext to the name of (alias posix file #TEXPATH#)
	set texname to the do shell script  "echo "& quoted form of 
texname_ext & " | cut -d . -f 1"
	set texfiles to every file in texfolder whose name contains texname
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 not "tex") and (the name 
extension of this_file is not "pdf") 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

tell application "TeXShop" to 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 

if the button returned of the result is "Trash" then
	tell application "Finder" to move every item of files_to_delete to the 
end if

Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.

More information about the macostex-archives mailing list