The following script modify all files with extension ‘.ma’ in the current project path and subfolders, in this way you can easily edits all files in one shot . This script searching for a specific string replace_this variable and replace it with with_this variable , you can use it for changing references path , texture path etc…

import maya.cmds as cmds
import re
import glob, os

# – Define our search and replace
replace_this ='string you want to replace'
with_this = ""
# - Get your Project path
projectPath=cmds.workspace(q=True, rd=True)
scenesPath= projectPath+"scenes/"
# – Use a regex to do the substitution as that is very quick
regex = re.compile(replace_this)
for root, dirs, files in os.walk(scenesPath):
    for file in files:
        if file.endswith(".ma"):
             filepath = root+'/'+file
             with open(filepath, "r") as read_stream:
                with open(filepath, "w") as write_stream:
                    write_stream.write(regex.sub(with_this, lines))
print "Job Done..."

Hope this helps!
For any questions do not esitate to contact me!

Adriano Sanna - 2023 All rights reserved.