Hi
I am trying to write a script to run a bash script that has the absolute path to a file passed to it. I am using subproces to run the bash script and all files except for the mkv files are in the same folder
root = "/mnt/Anime/Series/-Akuyaku Reijou Level 99/"
# Scan directory for .mkv files
for root, directory, files in os.walk(root, topdown=True):
directory.sort()
for filename in sorted(files):
if filename.endswith(".mkv"):
full_path = os.path.join(root, filename)
print(f"{full_path}")
subprocess.call(["./file-rename.sh", f"{full_path}" ])
Unfortunately most of the example on the internet deal with passing commands so I am not even sure the way I doing it is possible.
Here is the output
madzi@Network-Rage:~/dev/linx-scripting/bash-scripts/bulk-rename$ python3 file-rename.py
/mnt/Anime/Series/-Akuyaku Reijou Level 99/[ASW] Akuyaku Reijou Level 99 - 01 [1080p HEVC].mkv
Traceback (most recent call last):
File "/home/madzi/dev/linx-scripting/bash-scripts/bulk-rename/file-rename.py", line 15, in <module>
subprocess.call(["./file-rename.sh", f"{full_path}" ])
File "/usr/lib/python3.11/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: './file-rename.sh'
Any help would be appreciated.