Last active
August 29, 2015 14:01
-
-
Save JonasGroeger/301db5e64afdcd90e71e to your computer and use it in GitHub Desktop.
Removes temporary LaTeX files. Can be customized to remove arbitrary files by extension or name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------------ | |
# Script: Clean-Temporary-Files.ps1 | |
# Author: Jonas Gröger <jonas.groeger@gmail.com> | |
# Date: 12.04.2014 | |
# Keywords: LaTeX, Clean, Delete, Remove, Temporary, Files | |
# Comments: Removes temporary files created by LaTeX etc. You can tweak it by | |
# adding extensions or specific files. | |
# ------------------------------------------------------------------------------ | |
Param( | |
[String] $Folder = $PSScriptRoot # By default, remove from current directory | |
) | |
$files_to_delete = @( | |
"*.aux", | |
"*.bbl", | |
"*.bcf", | |
"*.blg", | |
"*.brf", | |
"*.idx", | |
"*.ilg", | |
"*.ind", | |
"*.lof", | |
"*.log", | |
"*.lol", | |
"*.lot", | |
"*.lpr", | |
"*.nlo", | |
"*.nls", | |
"*.out", | |
"*.pyg", | |
"*.run.xml", | |
"*.synctex", | |
"*.synctex.gz" | |
"*.tdo", | |
"*.toc" | |
) | |
$n_files_removed = 0 | |
Get-ChildItem $Folder -Recurse -Include $files_to_delete | foreach ($_) { | |
Write-Host "Removing $($_ | Resolve-Path -Relative)" | |
Remove-Item $_.FullName | |
$n_files_removed++ | |
} | |
if($n_files_removed -eq 0) { | |
Write-Host "No files removed from: $Folder" | |
} else { | |
Write-Host "$n_files_removed files removed from: $Folder" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment