Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Run all FileBot argument .txt files in '_BatchOperations_' folder (https://www.filebot.net/forums/viewtopic.php?f=4&t=3244)
- 1) Place this script in the same folder as 'filebot.exe'
- 2) Run it to create the '_BatchOperations_' directory and a '.repeat' file
- 3) Add .txt files to the '_BatchOperations_' folder, each containing valid FileBot arguments (Refer to link above).
- 4) Run this script again, and it will scan the '_BatchOperations_' folder and run FileBot once for each .txt file found.
- * Optional: Automatically repeat the operation
- 0 == Repeat disabled (Default)
- If you'd like to re-run the filebot commands every X seconds, you can change the '0' in the '.repeat' file,
- which is inside the '_BatchOperations_' folder. Changing the value to anything >0 (numbers only) will enable repeats every X second.
- * If using this script as a .pyw or .exe, then you'll have to use TaskManager to kill the program
- """
- from pathlib import Path
- import subprocess
- import sys
- import time
- # ===== Dependencies =====
- filebot_exe = Path('./filebot.exe').resolve()
- batch_folder = filebot_exe.parents[0] / './_BatchOperations_/'
- repeat_file = batch_folder / './.repeat'
- batch_folder.mkdir(exist_ok=True, parents=True)
- if repeat_file.exists() is False:
- print(f"Creating .repeat file: {repeat_file}...")
- with repeat_file.open('w') as file:
- file.write('0')
- # ====== Main =====
- while True:
- filebot_args = list(batch_folder.glob('*.txt'))
- if len(filebot_args) >= 1:
- for file in filebot_args:
- print(f"Running argument file: {file}")
- subprocess.run([str(filebot_exe), f"@{str(file)}"], creationflags=0x08000000)
- else:
- print('No argument files found, exiting...')
- break
- try:
- with repeat_file.open('r') as repeat:
- sleep_time = int(repeat.read())
- if sleep_time == 0:
- print('Repeat disabled, exiting...')
- break
- elif sleep_time < 0:
- print(f"Sleep time must be a positive number not \'{sleep_time}\', exiting...")
- break
- else:
- print(f"Sleeping for {sleep_time} seconds")
- time.sleep(sleep_time)
- except ValueError as e:
- print(f"File does not contain a valid number, exiting...\n\n{e}")
- break
- sys.exit()
Add Comment
Please, Sign In to add comment