After digging through the comments section, I think I may have a solution for OP's problem. As usual, the question seems to be an X vs Y issue, where OP asks for something but expects something else in return.
So, in accordance to OP's comments, here's a possible implementation.
import os
import inspect
# Assuming you have a project with the following tree structure:
''''<current_dir>
my_script.py
ORIGINAL PARAMS
PARAM.SFO
...
PATCHED PARAMS
notPARAM.SFO
PARAM.SFO
PARAM(1).SFO
PARAM(2).SFO
...
'''''
# The following script will list the contents of PATCHED PARAMS, filter all files that start with PARAM, then for each
# open the source_filename, read it, replace all \x85 binary characters with \xA5 characters in the bytestream
# and write the resulting bytestream to the previously opened PARAM* file.
# Do note that opening a file with wb will either create it if it does not exist, or completely overwrite it
# In order to avoid problems with relative paths, we get the current directory of the script
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
# Knowing the relative structure of our project, we could always assume that the target of our script is in the
# same PATCHED PARAMS folder, so we save that path as another script variable
patched_params_directory = 'PATCHED PARAMS'
patched_params = os.path.join(currentdir, patched_params_directory)
# This would be the initial source file that contains the values (the one you read and get the value to replace)
original_directory = 'ORIGINAL PARAMS'
original_filename = 'PARAM.SFO'
# And this would be it's full path. This is here to avoid issues with relative paths
source_filename = os.path.join(currentdir, os.path.join(original_directory, original_filename))
# This is the prefix of all the files we want to alter
params_file_prefix = 'PARAM'
# For every file in the contents of the PATCHED PARAMS directory that starts with PARAM
# So for example PARAM(1) would be accepted, while 1PARAM would not
# param or PaRaM would also not be accepted. If you want those to be accepted, cast both filenames and prefix to lower
for file in [_ for _ in os.listdir(patched_params) if _.startswith(params_file_prefix)]:
# Calculate the destination filename based on our filter
dest_filename = os.path.join(patched_params, file)
# Open both source and dest files, parse the source, write changes to dest
with open(dest_filename, 'wb') as f, open(source_filename, 'rb') as p:
f.write(p.read().replace(b'\x85', b'\xA5'))