Hello Guest, if you are reading this it means you have not registered yet. Please take a second, Click here to register, and in a few simple steps you will be able to enjoy our community and use our OpenViX support section.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Orphan file cleanup?

  1. #1

    Title
    Junior Member
    Join Date
    Nov 2018
    Posts
    12
    Thanks
    1
    Thanked 4 Times in 1 Post

    Orphan file cleanup?

    I have my Vu+ Solo2 save all recordings to a NAS drive, which I then point Plex at so I can view the videos in Plex (directly as a Plex library rather than as Plex DVR).

    This all works great, however... If I then delete one of the videos from Plex it will delete the .ts file, but leaves the other files in situ (.eit, .ts.ap, .ts.cuts, .ts.meta and .ts.sc)

    Is there a way of having these automatically cleaned-up to remove the orphaned files?

    Thanks

  2. #2
    abu baniaz's Avatar
    Title
    Moderator
    Join Date
    Sep 2010
    Location
    East London
    Posts
    23,358
    Thanks
    6,439
    Thanked 9,160 Times in 6,235 Posts
    Not a direct answer to what you asked, but I use the "event name first" in the recording composition option. This makes manipulation of files clearer using PC.

    Until you get a fix, you could try selecting all and moving to another directory. That will leave the orphan files in the original directory.

  3. #3

    Title
    Junior Member
    Join Date
    Nov 2018
    Posts
    12
    Thanks
    1
    Thanked 4 Times in 1 Post

    Lightbulb

    I've managed to create a script that will do this for me:

    Code:
    #! /bin/bash
    
    path=/data/media/FreeSat
    
    for file in "$path"/*.{ts.ap,ts.cuts,ts.meta,ts.sc,eit} ; do
        filename=$(basename -- "$file")
        testfile="$path/${filename%%.*}.ts"
        if ! [ -e "$testfile" ]
        then
           echo "$testfile doesn't exit"
           echo "    deleting $file"
           echo
           rm -- "$file"
        fi
    done
    I'm going to run this from Cron on my NAS - should do the trick nicely.

    Basically, it looks at that folder and finds any files eit, ts.ap, ts.cuts, ts.meta or ts.sc files that don't have an accompanying .ts file and deletes them.

    My bash isn't the greatest, so I'm sure it can be improved, but it does the job!

    Hope it's useful.

  4. The Following 4 Users Say Thank You to derekoh For This Useful Post:

    abu baniaz (04-12-18),kryton (04-12-18),widar (04-12-18),Willo3092 (04-12-18)

  5. #4
    Willo3092's Avatar
    Title
    ViX Beta Tester
    Join Date
    Oct 2016
    Location
    East Midlands
    Posts
    1,062
    Thanks
    751
    Thanked 403 Times in 303 Posts
    I know I'm dredging up an old thread but does anyone know why this script is not running for me from scriptrunner?
    I've just changed the path.

    Code:
    #! /bin/bash
    
    path=/media/autofs/SERIES/test
    
    for file in "$path"/*.{ts.ap,ts.cuts,ts.meta,ts.sc,eit} ; do
        filename=$(basename -- "$file")
        testfile="$path/${filename%%.*}.ts"
        if ! [ -e "$testfile" ]
        then
           echo "$testfile doesn't exit"
           echo "    deleting $file"
           echo
           rm -- "$file"
        fi
    done
    2021-08-13_142528.jpg
    Last edited by Willo3092; 13-08-21 at 14:41.

  6. #5
    ccs's Avatar
    Title
    ViX Beta Tester
    Join Date
    Sep 2014
    Posts
    5,836
    Thanks
    554
    Thanked 1,277 Times in 1,089 Posts
    Only a guess, should there be a space after #! or doesn't it matter?

  7. #6
    Willo3092's Avatar
    Title
    ViX Beta Tester
    Join Date
    Oct 2016
    Location
    East Midlands
    Posts
    1,062
    Thanks
    751
    Thanked 403 Times in 303 Posts
    Quote Originally Posted by ccs View Post
    Only a guess, should there be a space after #! or doesn't it matter?
    No, it doesn't seem to make any difference.

  8. #7
    Willo3092's Avatar
    Title
    ViX Beta Tester
    Join Date
    Oct 2016
    Location
    East Midlands
    Posts
    1,062
    Thanks
    751
    Thanked 403 Times in 303 Posts
    It works fine from Putty though

  9. #8
    Willo3092's Avatar
    Title
    ViX Beta Tester
    Join Date
    Oct 2016
    Location
    East Midlands
    Posts
    1,062
    Thanks
    751
    Thanked 403 Times in 303 Posts
    I get the same error if I try to run it as a scheduled task directly from my NAS:

    Dear user,

    Task Scheduler has completed a scheduled task.

    Task: delete_orphans
    Start time: Fri, 13 Aug 2021 16:25:09 GMT
    Stop time: Fri, 13 Aug 2021 16:25:09 GMT
    Current status: 2 (Interrupted)
    Standard output/error:
    /volume4/E2/NAS-scripts/delete_orphans.sh: line 2: $'\r': command not found
    /volume4/E2/NAS-scripts/delete_orphans.sh: line 4: $'\r': command not found
    /volume4/E2/NAS-scripts/delete_orphans.sh: line 5: syntax error near
    unexpected token `$'do\r''
    /volume4/E2/NAS-scripts/delete_orphans.sh: line 5: `for file in
    "$path"/*.{ts.ap,ts.cuts,ts.meta,ts.sc,eit} ; do
    '


    From DS916plus

    But working fine from putty.

  10. #9
    ccs's Avatar
    Title
    ViX Beta Tester
    Join Date
    Sep 2014
    Posts
    5,836
    Thanks
    554
    Thanked 1,277 Times in 1,089 Posts
    Quote Originally Posted by Willo3092 View Post
    It works fine from Putty though
    Works ok for me using putty and also windows telnet.

    Are you sure the script is using unix eol characters?
    Last edited by ccs; 13-08-21 at 16:44.

  11. #10
    Willo3092's Avatar
    Title
    ViX Beta Tester
    Join Date
    Oct 2016
    Location
    East Midlands
    Posts
    1,062
    Thanks
    751
    Thanked 403 Times in 303 Posts
    Quote Originally Posted by ccs View Post
    Works ok for me using putty and also windows telnet.

    Are you sure the script is using unix eol characters?
    You've lost me there! I've just pasted the script exactly as it is.
    I would like to automate it if possible, rather than using putty, either as a cron job on my box or as a scheduled task from my NAS.

  12. #11
    ccs's Avatar
    Title
    ViX Beta Tester
    Join Date
    Sep 2014
    Posts
    5,836
    Thanks
    554
    Thanked 1,277 Times in 1,089 Posts
    .... you need to paste it into something like notepad++, and make sure you're creating a unix file (option edit/EOL conversion), not a windows of mac file.

  13. The Following User Says Thank You to ccs For This Useful Post:

    Willo3092 (13-08-21)

  14. #12
    Willo3092's Avatar
    Title
    ViX Beta Tester
    Join Date
    Oct 2016
    Location
    East Midlands
    Posts
    1,062
    Thanks
    751
    Thanked 403 Times in 303 Posts
    I always use Notepad++ anyway, brilliant editor

    Anyway I managed to sort it by actually pasting the script in as a daily scheduled task on the NAS rather than entering the link to the bash script.
    All tested and working fine. This is the script with my recordings path in case it helps anyone else:

    Code:
    #!/bin/bash
    
    path=/volume1/Recordings
    
    for file in "$path"/*.{ts.ap,ts.cuts,ts.meta,ts.sc,eit} ; do
        filename=$(basename -- "$file")
        testfile="$path/${filename%%.*}.ts"
        if ! [ -e "$testfile" ]
        then
           echo "$testfile doesn't exit"
           echo "    deleting $file"
           echo
           rm -- "$file"
        fi
    done
    Thanks for the help and big thanks to @derekoh who wrote the script.
    Last edited by Willo3092; 13-08-21 at 18:26.

  15. #13
    BrokenUnusableAccount
    Be very careful with this.
    I just tried it and it messed up about 20 recordings that were playable before.

  16. #14
    BrokenUnusableAccount
    Quote Originally Posted by BefuddledBrian View Post
    Be very careful with this.
    I just tried it and it messed up about 20 recordings that were playable before.
    The problem is to do with when the file name minus extension ends with a full stop or multple full stops.
    It checks for the wrong .ts file!

    If you have:
    "20210423 0013 - BBC One HD - Greta Thunberg_ A Year to....eit"

    It will look for
    "20210423 0013 - BBC One HD - Greta Thunberg_ A Year to.ts"
    when it should be looking for
    "20210423 0013 - BBC One HD - Greta Thunberg_ A Year to....ts"
    and it will fail to find it and delete the .eit file!

  17. #15
    ccs's Avatar
    Title
    ViX Beta Tester
    Join Date
    Sep 2014
    Posts
    5,836
    Thanks
    554
    Thanked 1,277 Times in 1,089 Posts
    .... cheers, I just tested that the script ran, having first taken out the rm command just in case.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.