Skip to content

Instantly share code, notes, and snippets.

@splintax splintax/mtags-find-orphans.ps1 Secret
Last active Dec 12, 2018

Embed
What would you like to do?
# Set this to $true if you want the script to print successfully-located
# files in green. Useful to check that the script is working properly,
# but will make it harder to figure out which files are broken.
$showLocatedFiles = $false
# Find all !.tags files in the folder hierarchy starting in the current folder.
ls -rec "!.tags" | % {
# For each !.tags file, keep track of its parent directory ...
$parent = $_.Directory
# ... and search its JSON for "@" keys, which are relative paths.
gc -lit $_ | jq -r '..|.\"@\"?' | % {
# For each relative path, reconstruct an absolute path by adding back the
# parent directory and stripping any in-file location (eg. foo.cue|1).
join-path $parent ($_ -split "\|")[0]
# Remove duplicates (caused by multi-track *.cues).
} | gu | % {
# Print output.
if (test-path -lit $_) {
if ($showLocatedFiles) {write-host -f green $_}
} else {
write-host -f red $_
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.