[Windows] Relative paths in portable mode
#1
Question 
Hi there,

xbmc portable mode is a bit "dumb" if we are using it on different computers, it only works if the driver letter is always the same, so, whats the point?

It would be nice if xbmc portable mode got a way to use relative paths by default or a script maybe. I use xbmc on my computer, it`s installed in my external HDD, if I want to take my stuff (xbmc + media) to a friend, if the drive letter is different from mine I have to manually change it.

A nice feature(script maybe) would be to xbmc detect an "media" folder inside the installation/xbmc folder regardless the driver letter for the HDD.

Thanks

Sorry for my bad english
Reply
#2
XBMC works perfectly in portable mode on any drive for me.

What aspect of 'portable' isn't working for you?

Please make sure you're running xbmc.exe -p
(-p = portable mode)

The entire function of XBMC will then work on ANY drive and can be moved from drive to drive without any problem, all your user data / config is stored under the XBMC folder making the installation 100% portable.

If you are talking about it being unable to find the 'media' - because the media has changed drive letter, then you're correct, it will not find the media.

You can fix this in a number of ways:

1) Make sure your media resides on a drive letter that's always available. Or use the 'Subst' command to map a drive letter to your media (e.g. Subst Z: F:\My Media)

2) Use symbolic links as I do (if you're using Vista or later).

Here is my portable XBMC script which you can use (XBMCPORTABLE.BAT):

Code:
@Echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%~dp0."

Rem ****** Create Virtual Media Folders ********
rd /S /Q "x:\Virtual Media Folders"
mkdir "x:\Virtual Media Folders"

mklink /D "x:\Virtual Media Folders\Backdrops 01"    "X:\Media Folders\Backdrops 01"
mklink /D "x:\Virtual Media Folders\Movies 01"       "D:\Data\Videos\Movies"
mklink /D "x:\Virtual Media Folders\Movies 02"       "\\COMPAQ-PC\Movies 02"
mklink /D "x:\Virtual Media Folders\Music 01"        "\\COMPAQ-PC\Music 01"
mklink /D "x:\Virtual Media Folders\Music Videos 01" "\\COMPAQ-PC\Music Videos 01"
mklink /D "x:\Virtual Media Folders\TV Series 01"    "\\COMPAQ-PC\TV Series 01"
mklink /D "x:\Virtual Media Folders\TV Series 02"    "\\COMPAQ-PC\TV Series 02"


Rem ****** Launch XBMC ********
start /B x:\XBMC\XBMC.exe -p


Here's how I structure my installation:

D:\XBMC\
D:\XBMC\XBMCPRTABLE.BAT <--- the launcher!
D:\XBMC\Virtual Media Folders\
D:\XBMC\Virtual Media Folders\Movies 01 <------ VIRTUAL folders
D:\XBMC\Virtual Media Folders\TV Series 01
D:\XBMC\Virtual Media Folders\etc
D:\XBMC\XBMC <----- the REAL XBMC folder

Here's what the batch file does:

1) It ALWAYS makes sure XBMC is running from drive 'X' regardless of there it's physically located. This is done by mapping Drive X to the XBMC installation.

2) It then creates a folder called 'Virtual Media Folders', and within that folder creates VIRTUAL folders (via symbolic links) to my real media folders.
*** Critical note: you MUST setup XBMC sources to point to these folders (i.e. ALWAYS X:\Virtual Media Folders\xxxxxx)

3) It then launches XBMC in portable mode.


So why is this cool?

It's cool because you can move ANY of your real media folders to any disk drive you like, and all you have to do is update your VIRTUAL folders to point to the new location.
XBMC is 'fooled' because it always finds media via the X:\virtual media folders\xxxxx mapping. This way XBMC AND the media become truly portable.


If you don't understand any of the above, just let me know and I'll try to make it clearer.


Good luck!
Reply
#3
Thumbs Up 
Many Many Thanks Wink I thing It's working perfectly Wink

My "XBMC Start Here.bat" Smile
Code:
@Echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%~dp0."
Rem ****** Create Virtual Media Folders ********

rd /S /Q "x:\Virtual Media Folders"
mkdir "x:\Virtual Media Folders"

mklink /D "X:\Virtual Media Folders\Movies"    "X:\Media Folders\Movies"
mklink /D "x:\Virtual Media Folders\TV Series"    "X:\Media Folders\Tv Series"

Rem ****** Launch XBMC ********
start /B x:\XBMC\XBMC.exe -p

If I only use the folders inside the XBMC can I only use this:?
Code:
@Echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%~dp0."

Rem ****** Launch XBMC ********
start /B x:\XBMC\XBMC.exe -p
Reply
#4
If you are certain you will never want to move your media around (and always keep it with xbmc, then a single 'Subst' will work, yes :-)

The golden rule is to make sure XBMC scans the media using your subst drive (this way it's in the database as 'X:\').


I just prefer the symbolic link (mklink) method because it's ultimately more flexible.

Great that it's working for you :-)
Reply
#5
AnalogKid Wrote:If you are certain you will never want to move your media around (and always keep it with xbmc, then a single 'Subst' will work, yes :-)

The golden rule is to make sure XBMC scans the media using your subst drive (this way it's in the database as 'X:\').


I just prefer the symbolic link (mklink) method because it's ultimately more flexible.

Great that it's working for you :-)

Working great! Thanks! Wink
Reply
#6
i think this is one of the best methods to use xmbc in a portable way.
i just used this bat:

Code:
@Echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%cd%"


Rem ****** Launch XBMC ********
start /B x:\XBMC\XBMC.exe -p

***look at the subst X: "%cd%" is for compatibility with the exe compiler xD


and then compiled to exe with a freeware (bat to exe)
now i put my usb in anycomputer (windows vista or seven) and run that exe.
Reply
#7
(2011-02-14, 15:26)AnalogKid Wrote: XBMC works perfectly in portable mode on any drive for me.

What aspect of 'portable' isn't working for you?

Please make sure you're running xbmc.exe -p
(-p = portable mode)

The entire function of XBMC will then work on ANY drive and can be moved from drive to drive without any problem, all your user data / config is stored under the XBMC folder making the installation 100% portable.

If you are talking about it being unable to find the 'media' - because the media has changed drive letter, then you're correct, it will not find the media.

You can fix this in a number of ways:

1) Make sure your media resides on a drive letter that's always available. Or use the 'Subst' command to map a drive letter to your media (e.g. Subst Z: F:\My Media)

2) Use symbolic links as I do (if you're using Vista or later).

Here is my portable XBMC script which you can use (XBMCPORTABLE.BAT):

Code:
@Echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%~dp0."

Rem ****** Create Virtual Media Folders ********
rd /S /Q "x:\Virtual Media Folders"
mkdir "x:\Virtual Media Folders"

mklink /D "x:\Virtual Media Folders\Backdrops 01"    "X:\Media Folders\Backdrops 01"
mklink /D "x:\Virtual Media Folders\Movies 01"       "D:\Data\Videos\Movies"
mklink /D "x:\Virtual Media Folders\Movies 02"       "\\COMPAQ-PC\Movies 02"
mklink /D "x:\Virtual Media Folders\Music 01"        "\\COMPAQ-PC\Music 01"
mklink /D "x:\Virtual Media Folders\Music Videos 01" "\\COMPAQ-PC\Music Videos 01"
mklink /D "x:\Virtual Media Folders\TV Series 01"    "\\COMPAQ-PC\TV Series 01"
mklink /D "x:\Virtual Media Folders\TV Series 02"    "\\COMPAQ-PC\TV Series 02"


Rem ****** Launch XBMC ********
start /B x:\XBMC\XBMC.exe -p


Here's how I structure my installation:

D:\XBMC\
D:\XBMC\XBMCPRTABLE.BAT <--- the launcher!
D:\XBMC\Virtual Media Folders\
D:\XBMC\Virtual Media Folders\Movies 01 <------ VIRTUAL folders
D:\XBMC\Virtual Media Folders\TV Series 01
D:\XBMC\Virtual Media Folders\etc
D:\XBMC\XBMC <----- the REAL XBMC folder

Here's what the batch file does:

1) It ALWAYS makes sure XBMC is running from drive 'X' regardless of there it's physically located. This is done by mapping Drive X to the XBMC installation.

2) It then creates a folder called 'Virtual Media Folders', and within that folder creates VIRTUAL folders (via symbolic links) to my real media folders.
*** Critical note: you MUST setup XBMC sources to point to these folders (i.e. ALWAYS X:\Virtual Media Folders\xxxxxx)

3) It then launches XBMC in portable mode.


So why is this cool?

It's cool because you can move ANY of your real media folders to any disk drive you like, and all you have to do is update your VIRTUAL folders to point to the new location.
XBMC is 'fooled' because it always finds media via the X:\virtual media folders\xxxxx mapping. This way XBMC AND the media become truly portable.


If you don't understand any of the above, just let me know and I'll try to make it clearer.


Good luck!

Sorry I am having trouble getting folder inside the x:/Virtual Media Folders (Movies 01 Movies 02 etc) to create so cannot add them to sources in xbmc. If my starting drive letter in J is there anything in the code i need to change?

Could you please go through it in more detail
Reply
#8
OK, the first thing it does it create a 'X' drive.
The 'X' drive is the drive that XBMC will be mapped onto. You can make this any drive you like, but X is the one that I use.

The second thing is does is create a folder called 'Virtual Media Folders' (in the X Drive)
This is erased and regenerated every time the .Bat file is run.

The third thing it does is create symbolic links inside the 'Virtual Media Folders' folder. This is the crucial 'trick'.
Each symbolic link acts as a 'fake' folder than points to a 'real' folder where your media really resides.
When you configure XBMC, you should only ever use the 'Virtual Media Folders' (and subfolders) as your source (all on the X drive) - by doing this, you can then change your 'real' media folders whenever you like, and XBMC will still work :-)

If you are having trouble with the MKLINK command, you probably need to run the batch file as an administrator.

Let me know if that works for you.



Reply
#9
Hi AK,

Thanks for getting back to me so quickly,

I think you might be on the right track with running as admin, but I am a bit unsure how to run a batch as admin. Even so there is no warning to say 'you cant create link without admin' which other people seem to be getting.

What your saying makes perfect sense, and my batch does create X drive, and run XBMC from it. My only issue is none of my mapped mklink folders show up inside the Virtual Media Folders on the X Drive.

My Code is
Code:
@Echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%~dp0."

Rem ****** Create Virtual Media Folders ********
rd /S /Q "x:\Virtual Media Folders"
mkdir "x:\Virtual Media Folders"

mklink /D "X:\Virtual Media Folders\TV and Movies"    "X:\TV and Movies"
mklink /D "X:\Virtual Media Folders\Weather"          "X:\Weather"


Rem ****** Launch XBMC ********
start /B x:\XBMC\XBMC.exe -p

Everything is on D Drive on my current computer to begin with ie
D:\TV and Movies
D:\Weather
D:\XBMC
D:\XBMC\XBMCPORTABLE.bat
D:\XBMC\XBMC

When I run the BAT, X drive is created and this is what appears on it
X:\Virtual Media Folders ("TV and Movies" and "Weather" Folders don't show up here)
X:\XBMC
X:\XBMC\XBMCPORTABLE.bat
X:\XBMC\XBMC

There is also a Virtual Media Folders created on the D Drive D:\XBMC\Virtual Media Folders, should this be happening?

Any ideas?
Reply
#10
Hello All. After few trials, managed to use relative path [\Anime\Jap Sub En\0-9], but the scrapper wouldn't well scrap...
I did use then special://xbmc/../../Anime/Jap Sub En/0-9 with XBMC being in a _\Xbmc folder, and it is scraping using anidb.

If you go in portable data\userdata\sources.xml, you can add the sources manually not to type every one, and if you have splited into 0-9 and A to Z like me you will have something like:

Code:
<sources>
    <programs>
        <default pathversion="1"></default>
    </programs>
    <video>
        <default pathversion="1"></default>
        <source>
            <name>Anime Jap Sub En</name>
            <path pathversion="1">\Anime\Jap sub En\0-9\</path>
        </source>
        <source>
            <name>Anime Jap Sub En Relative Special</name>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/0-9/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/A/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/B/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/C/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/D/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/E/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/F/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/G/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/H/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/I/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/J/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/K/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/L/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/M/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/N/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/O/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/P/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/Q/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/R/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/S/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/T/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/U/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/V/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/W/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/X/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/Y/</path>
            <path pathversion="1">special://xbmc/../../Anime/Jap sub En/Z/</path>
        </source>
    </video>
    <music>
        <default pathversion="1"></default>
    </music>
    <pictures>
        <default pathversion="1"></default>
    </pictures>
    <files>
        <default pathversion="1"></default>
    </files>
</sources>

EDIT: Relative path using "special://xbmc/../" works even with scraping but if you got 4TB of anime, will get you banned when reaching letter "S". I used the anidb mod 1.1.0 and put the delay in the plugin to 200 before starting, didn't help too much. Unless somebody has a tip, will have to split it into A-M and N-Z. Apparently running a "Ping -t" on the anidb ip could help letting udp port longer on some providers however i believe the anidb mod uses http... Will try back using "../../" type of relative path, but scraping metadata info didn't work on my last attempt, but was just discovering scraping...
Reply
#11
Thanks. The special://xbmc/../ works great for me
Reply
#12
So Kodi doesn't use relative paths in portable mode?
Is portable only with hacks?
Reply
#13
I used answer 6 but added hiding the X drive that shows in Windows Explorer:

@echo off
Rem ****** Map X: to this folder *********
subst X: /D
subst X: "%cd%"

::Hide X Drive from Windows Explorer:
regedit /s X:\Kodi\hide_x_drive.reg

::Start Kodi:
start /B X:\Kodi\Kodi.exe -p

hide_x_drive.reg:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDrives"=dword:08388608
Reply

Logout Mark Read Team Forum Stats Members Help
[Windows] Relative paths in portable mode1