Skip to content

Instantly share code, notes, and snippets.

@JonasGroeger
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonasGroeger/301db5e64afdcd90e71e to your computer and use it in GitHub Desktop.
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.
# ------------------------------------------------------------------------------
# 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