Jump to content
LaunchBox Community Forums

Absolute file paths


KajQrd

Recommended Posts

I was wondering if there is a way to have the file paths always be absolute? I have just moved my installation from my hard drive to an SSD which certainly has sped up operations considerably. But when I try to launch any game from the hard drive the software doesn't find them because it is using something like ..\..\game library instead of the logical d:\Games\game library. Is there a setting anywhere in the options to have launchbox always use absolute paths and if there isn't would it be possible to create this? I'd say it should actually be the default option as it would actually make launchbox portable whereas with the current way of doing it it does create a LOT of work if you decide to move your installation folder.

Link to comment
Share on other sites

Both situations have their positives and negatives, but no, it wouldn't be more portable to always use absolute paths. Always using absolute paths would mean you couldn't move anything anywhere without causing issues.

That said, I can see the use for a setting that allows absolute paths to be used, but we don't have that as of yet. Honestly, I don't believe it's been a common request (this actually may be the first time), so unfortunately it probably isn't going to be prioritized any time soon.

Link to comment
Share on other sites

  • 3 months later...
On 10/29/2021 at 11:45 PM, Jason Carr said:

Both situations have their positives and negatives, but no, it wouldn't be more portable to always use absolute paths. Always using absolute paths would mean you couldn't move anything anywhere without causing issues.

That said, I can see the use for a setting that allows absolute paths to be used, but we don't have that as of yet. Honestly, I don't believe it's been a common request (this actually may be the first time), so unfortunately it probably isn't going to be prioritized any time soon.

I think an absolute path checkbox for game launch with a launchbox item list setting for drive letter priority could be really useful for a lot of people. I use it to start game copies temporarily from an ssd, on another pc with changing drive letter names like a gpd win 2 etc.

You can already do this with LaunchBox by setting up an emulator entry which uses only the filename as an parameter, replacing the paths backslash with file name unsupported characters (I use |?| for example - you can also add a dummy file ending for emulators with multiple file formats) and setting up a custom .exe redirecting to the game/emulator with the correct game path.

Below is a simple batch example for launching any .exe game this way. You have to replace all "\" occurences inside a platform .xml file (located inside "LaunchBox\Data\Platforms") with "|?|" and every relative path beginning "..\..\" with a drive letter like "C:|?|" for this script to work. Also remove all root folder paths via regex by replacing "<RootFolder>.*?</RootFolder>" with "<RootFolder />" (I recommend using Notepad++). After that you can then convert this .bat code below to an .exe with bat to exe converter for example and execute your PC games this way irrelevant of the drive letter.

@echo off

set _tail=%*
call set _tail=%%_tail:*%1=%%

set _args=%1
setlocal enabledelayedexpansion

rem replace custom string for backslash
set "_args=%_args:|?|=\%"

setlocal DisableDelayedExpansion
set "_args=%_args:~1,-1%"
set "_args=C:%_args%.exe"

rem skip drive check if preferred drive letter has game
if exist "%_args%" goto :next

rem replace ! and & temporarily before split
set "_args=%_args:!=exclamamarki%"
setlocal enabledelayedexpansion
set "_args=!_args:&=andsymbol!"
set "_args=!_args:(=rndbrackopen!"
set "_args=!_args:)=rndbrackclosed!"
setlocal DisableDelayedExpansion

for %%a in (%_args%) do (
    set gamefulli=%_args:~3%
    set cdrive=%%~da
)
set cdrive=%cdrive:~0,-1%

rem undo ! and & replace
setlocal enabledelayedexpansion
set "gamefulli=!gamefulli:andsymbol=&!"
set "gamefulli=!gamefulli:rndbrackopen=(!"
set "gamefulli=!gamefulli:rndbrackclosed=)!"
setlocal DisableDelayedExpansion
set "gamefulli=%gamefulli:exclamamarki=!%"

rem search drive letters with priority order
for %%i in (C D X E F G H I J K L M N O P Q R S T U V W Y Z) do if exist %%i: (
   if exist "%%i:%gamefulli%" (
	set "_args=%%i:%gamefulli%"
    goto :next
   )
)

:next

rem split folder path and name
For %%A in ("%_args%") do (
    Set Folder=%%~dpA
    Set Name=%%~nxA
)

rem go into .exe folder path
cd "%Folder%"

rem wait for an .exe to close to have functional launchbox pause screen
START /WAIT "launchbox-game" "%_args%" %_tail%
exit

 

Link to comment
Share on other sites

  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...