[OS X TeX] "Clean up" macro
Will Robertson
will at guerilla.net.au
Mon Aug 16 23:02:09 EDT 2004
Hi all
I've got a macro for you guys to test! If it's all good I'll add it to
my others for download. Comments of any sort are welcome! (Note that an
iTeXMac version is not planned immediately due to time constraints, but
is not hard to adapt - any volunteers?)
Anyway, you can customise the extensions list at the top if you wish
(I'm still accepting obscure extensions for the `final' version), and
there's a boolean you can set called delete_files_only_with_same_name.
Say you've got:
main.tex
main.aux
chap1.tex
chap1.aux
If you run the script with that flag as false (default), it will delete
both .aux files. Otherwise, as true, it will delete only the one
corresponding to the tex document you run the script on.
Hope it's useful!
Will
--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