Make all paths relative for a blend file via python
This will make all paths relative and then save
import bpy
bpy.ops.file.make_paths_relative()
bpy.ops.wm.save_mainfile()

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()'