Running multiple Alias Configs (for different computers)

If you use the same Alias configuration on several computers, you may have encountered the frustration of aliases breaking due to slightly different paths to a given file on each of the computers. To resolve this, I created the following code, which was inspired by code shared by @lxp Using Backup/Restore Configuration to share configuration with own PC or others? - #3 by r47926. Note that LXP's solution is also viable. My version allows you to run two completely separate Alias config's.


BACKUP YOUR ALIAS CONFIG BEFORE ATTEMPTING THIS!!!

This can be found in DOpusConfig\ConfigFiles\folderaliases.oxc

The solution consists of two BAT files which I run from the Favourites Bar.

  1. Imports an alias file, based on the name of the computer that you are currently on. To learn the name of your pc, open terminal or command prompt and type hostname. Adjust this code accordingly. The name must be CAPITALISED in the code. Then create a folder somewhere (I save mine in the DOPUS config folder.

DOpusConfig
└───Alias_chooser
├───Personal_Desktop
│ └───folderaliases.oxc
│
└───Personal_Laptop
└───folderaliases.oxc

The code below sets the config based on your PC name. It must be saved as a .bat file (e.g. set_alias_config.bat).

@echo off
setlocal
set "opusCfg=%APPDATA%\GPSoftware\Directory Opus\ConfigFiles"
set "machine=%COMPUTERNAME%"
cd /d "%opusCfg%"

echo Detected PC: %machine%

if exist folderaliases.oxc (
    del folderaliases.oxc
)

if /I "%machine%"=="PCNAME" (
    copy /Y "C:\Users\X\OneDrive\DOpusConfig\Alias_chooser\Personal_Laptop\folderaliases.oxc" folderaliases.oxc
    echo Copied Personal_Laptop aliases.
) else if /I "%machine%"=="PCNAME" (
    copy /Y "E:\OneDrive\DOpusConfig\Alias_chooser\Personal_Desktop\folderaliases.oxc" folderaliases.oxc
    echo Copied Personal_Desktop aliases.
) else (
    echo Unknown machine: %machine%
)

pause

  1. If you make changes based on the current session (e.g. add or remove aliases). The following code updates the source config, so that the next time that you import it on the current PC, the changes are reflected. It must also be saved as a .bat file.
@echo off
setlocal
set "opusCfg=%APPDATA%\GPSoftware\Directory Opus\ConfigFiles"
set "machine=%COMPUTERNAME%"

echo Detected PC: %machine%

if /I "%machine%"=="PCNAME2" (
    copy /Y "%opusCfg%\folderaliases.oxc" "C:\Users\X\OneDrive\DOpusConfig\Alias_chooser\Personal_Laptop\folderaliases.oxc"
    echo Saved current aliases to Personal_Laptop folder.
) else if /I "%machine%"=="PCNAME2" (
    copy /Y "%opusCfg%\folderaliases.oxc" "E:\OneDrive\DOpusConfig\Alias_chooser\Personal_Desktop\folderaliases.oxc"
    echo Saved current aliases to Personal_Desktop folder.
) else (
    echo Unknown machine: %machine%
)

pause

You will again need to adjust PC name and paths etc.

1 Like