Skip to content

Instantly share code, notes, and snippets.

@pale2hall
Created December 30, 2015 03:17
Show Gist options
  • Save pale2hall/60542d02f28305422c2c to your computer and use it in GitHub Desktop.
Save pale2hall/60542d02f28305422c2c to your computer and use it in GitHub Desktop.
# Run this file to rename flac files from file-name.flac to file-name.flac.part
# if they don't decode properly.
#####################################################################
import subprocess
import sys
import os
for root, dirs, files in os.walk('.'):
for filename in files:
if filename.endswith(".flac"):
try:
output = subprocess.check_output(["flac", "-t", "--totally-silent", filename])
returncode = 0
except subprocess.CalledProcessError as e:
output = e.output
returncode = e.returncode
if returncode == 1:
print "error for " + os.path.join(root,filename);
os.rename(os.path.join(root,filename), os.path.join(root,filename)+".part")
else:
print "success for " + filename;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment