After a data crash I have a couple of thousand files like this "f1288357332.blend". I'm not good at python but there must be a way to rename those files as batch after the Object or mesh name in the file. i got the code to rename after the material but not for the object or mesh name. And now i found out there are not only materials in the blend files.
import bpy
import os
filepath = bpy.data.filepath
basepath, filename = os.path.split(filepath)
newpath = os.path.join(basepath, "generated")
os.makedirs(newpath, exist_ok=True)
new_filename = ''
and iam a absolut beginner in python - someone here wrote the script Here is the my question for rename the script after material:
Batch-Rename-File-after-Material-Slot
import bpy
import os
import glob
from subprocess import call
BLEND_FILES_DIRECTORY = r"/path/to/your/blend/files" #example path: C:\Users\xxxx\Desktop\blendfiles
RENAME_SCRIPT = r"/path/to/rename-script.py" #example path: C:\Users\xxxx\Desktop\blendfiles\rename-script.py
for file in glob.glob(os.path.join(BLEND_FILES_DIRECTORY, '*.blend')):
basepath, filename = os.path.split(file)
print("process file:", filename)
call(['blender','-b', file, '-P', RENAME_SCRIPT])
That is the code for rename after the material but i need this to rename after the object file now. Can somebody help me?
obj_name = bpy.data.objects[:][0].name
and then substitute that into the rename part of the script, instead of using the material name. $\endgroup$bpy.data
$\endgroup$iam a absolut beginner in python - someone here wrote the script Here the orginal question: [Batch-Reanme](https://blender.stackexchange.com/questions/273349/batch-rename-a-blend-file-after-the-first-object-or-mesh-name-in-the-file)
Plus the link points to the current post. $\endgroup$