Search code examples
batch-filestreamkodi

Kodi - open .strm files by running a .bat / VBScript


I have legal .strm files of different TV Shows in a folder named TV Shows. Each strm file of each episode is stored in different subfolders.

I would like to run a certain VBScript before these strm files are played.

Then I have a different folder named MOVIES. Again, I would like to run a VBScript before these strm files are played. But this VBScript is a different one.

How would I do that?

Platform is Windows.

Thanks!


Solution

  • If you're looking to open or do something to each file based on extension, An easy way to do this is to use an for loop with /R to search all sub-directories for an *.strm file.

    @ECHO OFF
    SET "LOC=C:\Folder"
    
    CD %LOC%
    FOR /R %%A IN (*.strm) DO (
    
        Rem | Do something with each file.
        Start cmd.exe /C "notepad.exe "%%A""
    
    )
    
    Echo No More Items Found!
    pause
    goto :EOF
    
    • %%A will return the file path.
    • Start cmd.exe /C "" will start a CMD command. (Replace with your code)
    • notepad.exe "" will open the file (Used as an example)

    EDIT:

    So you're looking to check if the file exists then if true run the script? Bellow should solve that.

    @ECHO OFF
    
    If exist (C:/Path/file.strm) (
    
        Rem | File exists, run script
        Echo Do something
    
    )
    GOTO :EOF