Tools and other software Batch to update (or clean) my TV recordings folder (1 Viewer)

olli14

Portal Pro
December 17, 2008
738
35
Germany Germany
Country flag
I tested again and I found out that I can't use "load_file(filename)". It doesn't work.
E.g. I have the files "heute.ts" and "heute.txt" in the folder "c:\test". In the file "heute.txt" is a simple HELLO.
Now when I type
select load_file('c:/test/heute.ts');
I get as result NULL

WHen I type in
select load_file('c:/test/heute1.ts');
I get as result NULL

When I type in
select load_file('c:/test/heute.txt');
I get as result HELLO

Though the file heute.ts exists and the file heute1.ts doesn't exist the result is everytime NULL. So I can't use load_file command. Is there another command that is working?
 

pünktchen

Portal Pro
October 26, 2010
537
201
Germany Germany
Country flag
There's no "file exists" function in MySQL, because MySQL doesn't know anything about physical files. Load_File tries to read strings from a file, that's why it doesn't work for video files.But you could substitute the ts extension of "filename" with xml (replace funktion) and run Load_File against your xml's instead.

Or you could output the filename table as a list and run a real batch file against it to check for file existance and delete the non existend entries from the sql table.
 
Last edited:

olli14

Portal Pro
December 17, 2008
738
35
Germany Germany
Country flag
@pünktchen
I Don't understand what you mean with this "...But you could substitute the ts extension of "filename" with xml (replace funktion) and run Load_File against your xml's instead..." Can you send me a PN in german and give me some hints?
 

olli14

Portal Pro
December 17, 2008
738
35
Germany Germany
Country flag
The leading thought to make this conversation private was that no one has interest to my speciale problem. I thought. But you are right. Maybe someone is out there :)

maybe you had the same idea as I have now. I have a batch file that can delete all XML files, jpg files, txt files and so on where no corresponding ts files exists.

So I will test this:
1. I delete all XML files where no corresponding ts file exists.
2. I open the recording table and use this command: select replace('filename','.ts','.xml');
3. Then I use this command: DELETE FROM Recording WHERE LOAD_FILE(fileName) IS NULL;
4. Then I use this command: select replace('filename','.xml','.ts');
I will tell you about the result.
Or did you had another idea, mm1352000?
 

pünktchen

Portal Pro
October 26, 2010
537
201
Germany Germany
Country flag
The leading thought to make this conversation private was that no one has interest to my speciale problem. I thought. But you are right. Maybe someone is out there :)

maybe you had the same idea as I have now. I have a batch file that can delete all XML files, jpg files, txt files and so on where no corresponding ts files exists.

So I will test this:
1. I delete all XML files where no corresponding ts file exists.
2. I open the recording table and use this command: select replace('filename','.ts','.xml');
3. Then I use this command: DELETE FROM Recording WHERE LOAD_FILE(fileName) IS NULL;
4. Then I use this command: select replace('filename','.xml','.ts');
I will tell you about the result.
Or did you had another idea, mm1352000?
That was my idea. Unfortunately "load_file" seems to have a problem if "fileName" has special characters like german Umlauts.
 

CyberSimian

Test Group
  • Team MediaPortal
  • June 10, 2013
    1,980
    1,229
    Southampton
    United Kingdom United Kingdom
    Country flag
    The leading thought to make this conversation private was that no one has interest to my speciale problem. I thought. But you are right. Maybe someone is out there :)
    Yes, I am interested in a batch script to do this. Like you, I run my own batch script to re-arrange recordings (move them to appropriate locations in the "Videos" section), but I have to remember to start MP and manually use the "Clean Up" function. A neater solution would be for my script to issue some command to perform the clean up.

    Unfortunately, I have absolutely no knowledge of SQL, so cannot offer you any help. But I am interested in the outcome. (y)

    -- from CyberSimian in the UK
     

    pünktchen

    Portal Pro
    October 26, 2010
    537
    201
    Germany Germany
    Country flag
    Try this in a batch file:

    Code:
    @echo off
    chcp 1252
    
    set RECORDINGS=D:\Aufnahmen
    set MYSQL=C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe
    
    setlocal enabledelayedexpansion
    
    for /R %RECORDINGS% %%i in (*.xml) do (
        if not exist "%%~dpi%%~ni.ts" (
            set FILENAME=%%~dpi%%~ni.ts
            set FILENAME=!FILENAME:\=\\!
            echo SET CHARACTER SET 'latin1';> cleanup.sql
            echo DELETE FROM `mptvdb`.`recording` WHERE '!FILENAME!' = `fileName`>> Cleanup.sql
            timeout /t 5 /nobreak
            "%MYSQL%" --user=root --password=MediaPortal < Cleanup.sql
            del /f /q "%%~dpi%%~ni.xml"
            del /f /q "%%~dpi%%~ni.jpg"
            del /f /q Cleanup.sql
        )
    )
    
    exit
     

    olli14

    Portal Pro
    December 17, 2008
    738
    35
    Germany Germany
    Country flag
    Hi Pünktchen,
    I tested yesterday evening the Batch file. It did nothing. After starting the Batch I got a black small window for less than a second and that was all.
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    G Update von MediaPortal Installationsprobleme? 0
    morpheus_xx [Evaluate] Update to VS 2019? MediaPortal 2 4
    Golf4 Nach Windows-Updates läuft TV-Plugin nicht mehr Allgemeines Support- und Diskussionsforum 0
    B MPEM update list never completes. General Support 0
    JJDoherty Updated DTT frequencies for Ireland... Submit: EPG-Grabbers and tuningdetails 1
    Dark Eyes Updated to Windows 10, now TVServer won't work Installation, configuration support 1
    R [solved] Files moved to new location - Easy way to update database? My TVSeries 7
    M.Hulot Moving Pictures lässt sich nach Windows-Update nicht mehr öffnen Plugins & Erweiterungen 1
    R Files moved to different location - Easy way to update database? Moving Pictures 2
    k12158 [solved] Kein direkter Wechsel von TV-Kanal zu TV-Kanal mehr nach Update? Allgemeines Support- und Diskussionsforum 16
    ajs Mediaportal update to .Net 4.6.2+ MediaPortal 1 13
    Mr6686 [solved] Titan skin broken since update to 1.23 Installation, configuration support 6
    B TV-Server Auto-Update mptvdb after x hours General Support 0
    Terra LAVFilter Plugin cannot be updated (MP1.23) MediaPortal 1 Plugins 10
    TLD Windows 10 1903 feature update General Support 3
    azzuro [Pending] Update MP1 to VisualStudio 2019 MediaPortal 1 36
    A Problem Windows 10 64 bit prof. Update auf Version 1903(gelöst) Installationsprobleme? 0
    T No TV after updating Windows 10 to latest Version 1903 / OS build 18362.175 (logs attached) General Support 2
    M [solved] Updated Swedish translation for MP 1.24 Submit: Localization of MediaPortal and DeployTool 0
    framug 1.22.0 BasicHome Editor settings for DefaultWide HD skin not kept when update 1.22 3
    Neoculture Bulk file name update My TVSeries 6
    HTPCSourcer [Evaluate] MP2-Updates do not remove the GUID of previous installs MediaPortal 2 13
    Rob Hexenmeister [solved] Latests Media Handler - Skinning an updating window or control Fanart Handler 26
    H [solved] Problem bei Update auf 1.21 Installationsprobleme? 4
    A VB-IP SPAIN Movistar plus tunning details (Update 26 dec 2018) Submit: EPG-Grabbers and tuningdetails 1
    Similar threads

























    Top Bottom