# Make all paths relative for a blend file via python

I have a bunch of blend files, each in their own directory with supported files wherever necessary. I want to configure all the blend files to use relative paths. I can open each of them and do File > Externel Data > Make all paths relative. But since I've a lot of blend files, this is time consuming. Is it possible to do this via python script?

• Are they all in one directory or something? Apr 4 at 17:35
• No, they're in different directory. But I can run the same python script for each blend file. That, I've got it covered. I need to know how to set this setting via python for a single blend file. Apr 4 at 17:44
• Have you tried this? docs.blender.org/api/current/… Apr 4 at 17:49
• Thanks! I think that will work. I'll try it. I'm new to blender. How can I search for such things? i.e. how to do some things via python which I know how to do in GUI. I tried looking at blender python documentation, but I couldn't make head or tail out of it Apr 4 at 17:53
• In Preferences > Interface, turn on Python Tooltips. It will show you what to call in Python in the tooltip when you hover over a button. Apr 4 at 17:54

import bpy

You can run this from the shell like this. This should make all paths in file.blend relative
blender --background file.blend --python-expr 'import bpy;bpy.ops.file.make_paths_relative();bpy.ops.wm.save_mainfile()'