MacOS – Show/emphasize only certain types of files in finder

findermacos

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?

Best Answer

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.

--AppleScript
-- 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
    try
        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
        else
            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

[/endquote]

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