Skip to content

Instantly share code, notes, and snippets.

@ScribbleGhost
Last active March 7, 2023 15:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScribbleGhost/abac31424c97834eaa4a252b8ee53ffe to your computer and use it in GitHub Desktop.
Save ScribbleGhost/abac31424c97834eaa4a252b8ee53ffe to your computer and use it in GitHub Desktop.
import os
import subprocess
import shutil
from os import startfile
import codecs
# Check if FLAC.exe exists in PATH
if not shutil.which('flac') is not None:
print('\nSeems like FLAC.exe is missing...')
print('Please download FLAC from: https://xiph.org/flac/download.html')
print('Add it as to PATH, or edit the script to use the full path to the EXE')
exit(1) # Exit if it doesn't
# Clear content before writing to file
with open('FLAC errors.txt', 'w', encoding='utf-8') as log:
log.write('These FLAC files have errors:\n\n')
user_input = input('Enter the root file path of the music: ')
for base, dirs, files in os.walk(user_input):
for Files in files:
if Files.endswith('.flac'):
input_file = os.path.join(base, Files)
result = subprocess.run(
['flac', '--test', str(input_file)],
capture_output=True, shell=True,
)
if result.returncode == 0:
print('OK:', input_file)
if result.returncode != 0:
print('ERROR:', input_file)
# print(result.stdout.strip())
with open('FLAC errors.txt', 'a', encoding='utf-8') as log:
log.write(str(input_file)+"\n")
input('Press ENTER to exit')
startfile('FLAC errors.txt' )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment