import change_dir
import error_log
import input_check
import audio_gen
import init


# Initialize variables
init.init()

# Check inputs
input_check.input_check()

# Generate error log
error_log.log_gen()

# Counts the number of errors
print("Check complete!")
error_count = (
    len(init.empty_field_error_list)
    + len(init.invalid_char_error_list)
    + len(init.invalid_name_error_list)
    + len(init.oversize_name_error_list)
)
rename_count = len(init.filename_change_index)

# Decision making based on the number of errors
if len(init.filename_list) == 0:
    print("No files can be created due to errors.")
    print("Please see error_log.txt for more information.")
else:
    if error_count != 0 and rename_count != 0:
        print(f"A total of {error_count} error(s) were detected!")
        print(f"A total of {rename_count} file(s) were renamed!")
        print("Please see error_log.txt for more information.")
        change_dir.change_dir()
        audio_gen.audio_gen()
    elif error_count != 0 and rename_count == 0:
        print(f"A total of {error_count} error(s) were detected!")
        print("Please see error_log.txt for more information.")
        change_dir.change_dir()
        audio_gen.audio_gen()
    elif error_count == 0 and rename_count != 0:
        print(f"A total of {rename_count} file(s) were renamed!")
        print("Please see error_log.txt for more information.")
        change_dir.change_dir()
        audio_gen.audio_gen()
    else:
        change_dir.change_dir()
        audio_gen.audio_gen()

import change_dir
import error_log
import input_check
import audio_gen
import init


# Initialize variables
init.init()

# Check inputs
input_check.input_check()

# Generate error log
error_log.log_gen()

# Counts the number of errors
print("Check complete!")
error_count = (
    len(init.empty_field_error_list)
    + len(init.invalid_char_error_list)
    + len(init.invalid_name_error_list)
    + len(init.oversize_name_error_list)
)
rename_count = len(init.filename_change_index)

# Decision making based on the number of errors
if len(init.filename_list) == 0:
    print("No files can be created due to errors.")
    print("Please see error_log.txt for more information.")
else:
    if error_count != 0 and rename_count != 0:
        print(f"A total of {error_count} error(s) were detected!")
        print(f"A total of {rename_count} file(s) were renamed!")
        print("Please see error_log.txt for more information.")
        change_dir.change_dir()
        audio_gen.audio_gen()
    elif error_count != 0 and rename_count == 0:
        print(f"A total of {error_count} error(s) were detected!")
        print("Please see error_log.txt for more information.")
        change_dir.change_dir()
        audio_gen.audio_gen()
    elif error_count == 0 and rename_count != 0:
        print(f"A total of {rename_count} file(s) were renamed!")
        print("Please see error_log.txt for more information.")
        change_dir.change_dir()
        audio_gen.audio_gen()
    else:
        change_dir.change_dir()
        audio_gen.audio_gen()

# Initialize variables # Check inputs # Generate error log # Counts the number of errors # Decision making based on the number of errors