Skip to main content
windows paths need escaped backslash
Source Link
Harry McKenzie
  • 14.5k
  • 11
  • 34
  • 74

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder
# these paths I included below will probably need to be properly escaped, since windows is weird

recent_files = "C:\Users\<Userbane>\AppData\Roaming\Blender\\Users\\<Userbane>\\AppData\\Roaming\\Blender Foundation\Blender\<yourFoundation\\Blender\\<your-blender-version>\config\recentversion>\\config\\recent-files.txt" 

save_path = Path('C:\Desktop\my_blend\\Desktop\\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bpy.ops.wm.read_history()

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder
# these paths I included below will probably need to be properly escaped, since windows is weird

recent_files = "C:\Users\<Userbane>\AppData\Roaming\Blender Foundation\Blender\<your-blender-version>\config\recent-files.txt" 

save_path = Path('C:\Desktop\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bpy.ops.wm.read_history()

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder

recent_files = "C:\\Users\\<Userbane>\\AppData\\Roaming\\Blender Foundation\\Blender\\<your-blender-version>\\config\\recent-files.txt" 

save_path = Path('C:\\Desktop\\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bpy.ops.wm.read_history()
there was a typo in the script, but I cannot change only 1 character so I removed the hashtag, too
Source Link

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder
# these paths I included below will probably need to be properly escaped, since windows is weird #LinuxMasterRace

recent_files = "C:\Users\<Userbane>\AppData\Roaming\Blender Foundation\Blender\<your-blender-version>\config\recent-files.txt" 

save_path = Path('C:\Desktop\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bpbpy.ops.wm.read_history()

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder
# these paths I included below will probably need to be properly escaped, since windows is weird #LinuxMasterRace

recent_files = "C:\Users\<Userbane>\AppData\Roaming\Blender Foundation\Blender\<your-blender-version>\config\recent-files.txt" 

save_path = Path('C:\Desktop\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bp.ops.wm.read_history()

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder
# these paths I included below will probably need to be properly escaped, since windows is weird

recent_files = "C:\Users\<Userbane>\AppData\Roaming\Blender Foundation\Blender\<your-blender-version>\config\recent-files.txt" 

save_path = Path('C:\Desktop\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bpy.ops.wm.read_history()
Source Link
Jakemoyo
  • 7k
  • 11
  • 21

Blender stores your recent files in a txt file, [1][2] located in your OS' .config/blender/version/config/ folder. So once you save it, you just manually prepend the filepath to the beginning of that txt file and reread it in.

import bpy
from pathlib import Path

# recent files stored in a text file in your .config folder
# these paths I included below will probably need to be properly escaped, since windows is weird #LinuxMasterRace

recent_files = "C:\Users\<Userbane>\AppData\Roaming\Blender Foundation\Blender\<your-blender-version>\config\recent-files.txt" 

save_path = Path('C:\Desktop\my_blend.blend')
bpy.ops.wm.save_mainfile(filepath=save_path)

# add the blendfile path to the recent-files.txt
with open(recent_files, 'r+') as f:
    contents = f.read()
    f.seek(0,0) # go to beginning of file
    if save_path.is_file():
        newfile = save_path.resolve().rstrip('\n\r') + "\n" + contents
        f.write(newfile)
    else:
        print("File did not save correctly.")

# reread file history    
bp.ops.wm.read_history()