Add check for no-files-found

This commit is contained in:
Fred Boniface
2023-10-02 11:42:54 +01:00
parent 41c817f1fc
commit 79080d2752
2 changed files with 18 additions and 84 deletions

21
regain
View File

@@ -22,16 +22,26 @@
# SOFTWARE.
import os
import sys
import subprocess
import logging
import argparse
FORMATS = ["flac", "m4a", "aac", "alac", "mp3", "m3a", "ogg", "opus", "oga"]
PATH_TO_REGAINER = "./regainer.py"
DESCRIPTION = """
regain - Calls regainer.py on any albums found in subdirectories.
\n\n
Run the regain command in a directory that contains albums and ReplayGain tags will be
added to the files, including album tags.
\n\n
regain will walk through all subdirectories so can be run in your 'Music' folder, or
individual artist/album folders and tag as many albums as neccessary.
"""
def parse_arguments():
parser = argparse.ArgumentParser(description='Call regainer.py on subdirectories containing music files')
parser.add_argument('--debug', action='store_true', help='Enable debug logging')
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument('--debug', action='store_true', help='Enable debug logging (including regainer output)')
return parser.parse_args()
def configureLogging(debug_mode = False):
@@ -64,7 +74,12 @@ if __name__ == "__main__":
logging.debug("Debug logs enabled")
file_lists = find_files_by_extension(workdir)
logging.debug(f"File lists: {file_lists}")
logging.info(f"Files for processing: {countFiles(file_lists)}")
file_count = countFiles(file_lists)
if file_count == 0:
logging.error("No files to process")
print("You should run this command from the parent directory of any album folders")
sys.exit(1)
logging.info(f"Files for processing: {file_count}")
cmd = ["python", PATH_TO_REGAINER, "-f"]
for sublist in file_lists: