I use TeX a lot and it generates lots of auxiliary files that I am generally not interested in opening, and they clutter up my folders. Is there any way to make Finder automatically hide/gray-out files with certain extensions in Compact List or Column views, either for a specific folder or for all folders?

Alternatively, if this is not possible, can I customize the "view by file type" option to separate into my own categories based on file extension (e.g., category 1 would contain .tex and .pdf files, category 2 would contain .sty and .bib, and so on) and have them listed alphabetized by category?

  • Which LaTeX command do you need to run? If the files are of absolutely no interest for you, why keep them around for so long that they start to bother you in Finder? Might a redirect suffice pdflatex -output-directory=/some_temp_dir ? Commented Sep 1, 2017 at 23:20
  • @LangLangC I use TeXShop, which I think is set to use pdflatex. I do delete the auxiliary files for tex files I'm no longer actively working on, but there are many tex files I'm "actively" working on in many different directories, and it would slow typesetting down to delete them. Maybe putting them in another directory would work---do you know if I can easily do this globally (set it up once for all tex files on my system)?
    – Kimball
    Commented Sep 1, 2017 at 23:40
  • Globally? That depends. You can add the option I suggested to TeXShop>Preferences>Engine. That sends every generated file to your preferred folder. Then you'd sort for PDFs and fish these out again to the source folder. Commented Sep 1, 2017 at 23:56

1 Answer 1


One option would entail examining latexmk and rubber with their cleanup options.

But since cleaning up the .aux and related files is only recommended after the final compilation run anyway, the following seems to present a very neat solution for macOS users. One way to cleanup afterwards when you use TeXShop with its default settings is adding this flexible AppleScript to the program:

[quote] A TeXShop solution

As others have mentioned, deleting auxiliary files as a matter of course is not usually a good idea, especially for complex documents. However, it is useful to be able to delete them manually when needed.

I use the following Applescript (written by Claus Gerhardt) saved as a macro in TeXShop. The script could also be adapted to other Mac editors. What I like about this script is that I can add new aux file extensions when needed, and it is able to deal with multiple part aux extensions such as -blx.bib, etc.

-- Apply only to an already saved file
-- Claus Gerhardt, September 2006
(*This script gets the path of the frontmost (tex) document in TeXShop and removes the corresponding auxilary files the suffixes of which are listed in the list L. Beware of the quotation marks. The list L may contain suffixes to which no corresponding files exist.*)

my remove_auxiliaries()
on remove_auxiliaries()
    set L to {".aux", ".synctex.gz", ".fdb_latexmk", ".out", ".toc", ".bbl", ".blg", ".ind", ".sind", ".run.xml","-blx.bib",".log", ".end", ".1"} as list

    tell application "TeXShop"
        get path of document of window 1
        set fileName to result
    end tell

    set {baseName, texName, pdfName, namePath, dirName, dirNameunquoted, logName, logPath, rtfName, docName} to my setnamebbedit_rootn(fileName)

tell application "TeXShop"
    close document docName
end tell

repeat with x in L
        set shellScript to "cd " & dirName & ";"
        set shellScript to shellScript & "rm -f  " & baseName &  x
        do shell script shellScript
    end try
end repeat

end remove_auxiliaries

on setnamebbedit_rootn(x)
    set n to (number of characters of contents of x)
    set fileNamequoted to quoted form of x
    set windowName to do shell script "basename " & fileNamequoted
    set m to (number of characters of contents of windowName)
    set dirName to quoted form of (characters 1 thru (n - m - 1) of x as string)
    set dirNameunquoted to (characters 1 thru (n - m - 1) of x as string)
    set theText to contents of windowName as string

    set n to (number of characters of contents of theText)
    set i to n as number

    repeat while i > 0
        if character i of theText is equal to "." then
            set m to i
            exit repeat
            set i to (i - 1)
        end if
    end repeat

    set baseName to (characters 1 thru (m - 1) of theText as string)
    set texName to baseName & ".tex"
    set namePath to dirNameunquoted & "/" & baseName as string
    set pdfName to namePath & ".pdf" as string
    set rtfName to namePath & ".rtf" as string
    set logPath to namePath & ".log" as string
    set logName to baseName & ".log" as string

    set theFile to POSIX file x as string
    tell application "Finder"
        get displayed name of the file theFile
    end tell
    set docName to result

    return {baseName, texName, pdfName, namePath, dirName, dirNameunquoted, logName, logPath, rtfName, docName} as list
end setnamebbedit_rootn


copied from here (also take a look at the other suggestions)

  • Thanks. Incidentally, I just noticed apple.stackexchange.com/q/78853/111158 which is about the same problem, though the question itself is slightly different. So I guess the only "Finder-only solution" to this problem is with smart folders (as mentioned in an answer in that question)?
    – Kimball
    Commented Sep 2, 2017 at 11:57

Not the answer you're looking for? Browse other questions tagged .