# Choosing recent files list at startup

As a BSE user, I have to open many files from other users. The problem is that they're stored in the recent files list and my personal works are just disapearing.

I would like to choose a recent-files.txt when Blender starts, why not on splash screen, and be able to set one of them as default (when opening a file from explorer). Is it possible ?

• what i do is i always install the latest version ( this will be the default ) and i use it for testing , while i have an older version for my projects – Chebhou Aug 7 '15 at 11:04
• That's what I did, but I'd like to have only 1 stable version for BSE and personal/professional works – Bithur Aug 7 '15 at 11:07

The history file is managed by C code, see e.g. wm_files.c.

You could exchange the recent-files.txt by script maybe, then let Blender reload it by calling bpy.ops.wm.read_history() as seen in wm.py (everything else requires changes to the C code).

Example script that switches recent-files.txt and an also required recent-files-2.txt (you need to create this manually) and triggers a refresh of the Recent files list:

import bpy
import os

fp = bpy.utils.user_resource('CONFIG')
src = os.path.join(fp, "recent-files.txt")
tmp = os.path.join(fp, "recent-files-1.txt")
dst = os.path.join(fp, "recent-files-2.txt")

if os.path.exists(src) and os.path.exists(dst):
os.rename(src, tmp)
os.rename(dst, src)
os.rename(tmp, dst)



You could also append to recent-files.txt, or re-write it completely. Just keep in mind that Blender ignores files that do not exist, and will remove them from the text file.

• So with a python script it is possible replace the recent-files.txt (and save the replaced version) and load it? – Bithur Aug 7 '15 at 13:34
• Granted the host (probably Blender) has read/write access to the file, then the answer is probably yes. Moving and copying files is a general Python question however and not Blender related. – CodeManX Aug 7 '15 at 18:42
• i thought modifiying a blender file from blender would be blender related... – Bithur Aug 7 '15 at 18:48
• Renaming, moving or copying files does not involve Blender API. It's file I/O performed by the operation system. These operations can be carried out with os and shutil modules (and using them is definitely not Blender-related). recent-files.txt does not use a Blender-specific format either, it's a plain text file. What is related: how to determine the path to recent-files.txt and how to make Blender reload the file. Anyway, I added an example to my answer. – CodeManX Aug 7 '15 at 21:26

The recent files list is stored within blenders config directory. Blender searches three places to find it's config files, referred to as the local, user and system locations, see this page for platform specific variations. The first place searched is a local config folder that is in the same location as the datafiles installed with blender.

One way would be to keep two copies of blender, and create a local config folder for the 'SE' copy so that when you run the 'SE' copy you get a unique config which includes it's own recent files list.

You can also adjust the locations that are searched by setting the environment variable BLENDER_USER_CONFIG. The available environment variables can be listed by running blender --help in a terminal.

Environment Variables:
$BLENDER_USER_CONFIG Directory for user configuration files.$BLENDER_USER_SCRIPTS        Directory for user scripts.
$BLENDER_SYSTEM_SCRIPTS Directory for system wide scripts.$BLENDER_USER_DATAFILES     Directory for user data files (icons, translations, ..).
$BLENDER_SYSTEM_DATAFILES Directory for system wide data files.$BLENDER_SYSTEM_PYTHON    Directory for system python libraries.
$TMP or$TMPDIR                     Store temporary files here.
$SDL_AUDIODRIVER LibSDL audio driver - alsa, esd, dma.$PYTHONHOME                        Path to the python directory, eg. /usr/lib/python.

On a *nix system you can create a shell script called blender-se which sets this location before starting blender.

#/bin/sh
BLENDER_USER_BASE=/tmp/config/blender-se/
blender


Then when you call blender normally the normal config files will be used. On windows a similar .bat file could be used.

• Having 2 copies of blender is what i want to stop doing. Your solution is interesting and makes me think about the problem running 2 instances of blender with different configs... but that's another story i guess :) – Bithur Aug 7 '15 at 16:29
• If you setup a shell script to set the env variables then you can have one blender binary and 2...3... copies of config files. It may seem like you have multiple binaries, but instead just multiple settings, you could also setup the shell script to set the envVar based on an option sent, myblender se myblender clientone... – sambler Aug 7 '15 at 17:01
• let's say i've blender.exe in c:/blender/2.75 and config files in folders BSE and Perso in c:/blender/configs, what the .bat would be? (or command line). – Bithur Aug 7 '15 at 17:13
• I don't use windows, going by this and this - this bat file should be close. – sambler Aug 7 '15 at 19:57
• tried a lot of combinations but blender doesn't use it. I think it's some sort of blender local environment variables, not system or user. there's a " --env-system-datafiles" blender.exe argument but user environment variables seems to be a possible todo ( mail-archive.com/bf-blender-cvs@blender.org/msg65044.html ) – Bithur Aug 7 '15 at 21:36