1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. The forum software that supports hummy.tv will be upgraded on Sunday to XenForo 2.0 and so will be unavailable for periods during the day. This is a major upgrade which changes the look and feel of the forum somewhat but brings a host of improvements too. Please bear with us, there will doubtless be further style changes required following this work.

tidy-folders extension package

Discussion in 'HD/HDR-FOX T2 Customised Firmware' started by prpr, Oct 15, 2012.

  1. prpr

    prpr Well-Known Member

    Had to buy my mum a Fox T2 a few weeks ago to replace a failed Panasonic E85 (the common U81 error which has so far resisted the standard fixes).
    Anyway, managed to get the custom firmware on it a couple of weeks ago and have been tweaking since (from 150 miles away over a VPN!).
    I got really fed up with the Series Link recordings leaving empty folders around once the recordings were deleted, but didn't want to install "flatten", as I think the Series Link folders are useful... but not when they are empty, as they just clutter up the top level.
    So, I tried my hand at writing something to clear "empty" folders out, having looked at how some of the other extension packages were done - excellent site and instructions BTW.
    After a couple of days of frustration, I gave up trying to use shell script, as I don't really know it, and used C instead, which I do (tried C++ first but got loads of #include errors which I couldn't fix - have subsequently found the magic incantation to fix the compiler's Include path, but too late for this).

    Seems to work rather nicely. If anyone's interested, I guess I can submit it for inclusion?

    One question... in the Packages list on the web-if, it always comes up with a blank description. Is this expected for packages installed locally? The "control" file looks correct to me.
  2. Richyroo

    Richyroo New Member

    I would be very interested. I like the series folders so don't use flatten. I'm surprised no-one has developed this sooner!

    Sent from my Nexus 7
  3. prpr

    prpr Well-Known Member

    On here for now:
    You need to make sure the "cron" package is installed (it almost certainly is) as it's a dependency.
    I haven't bothered to make a proper bundle.
  4. prpr

    prpr Well-Known Member

    Sorry about having to munge the link. Forum s/w won't allow it until 10 posts. Better fill up this thread then :)

    A couple more words about how it works...
    It removes any empty (of .ts files) folders at the top level i.e. immediately below "My Video"
    and doesn't touch the "[Deleted Items]" folder (or whatever you may have renamed it as)
    at all if you have the "undelete" package installed.
    It doesn't touch any sub-folders either as these are not created automatically AFAIA.
  5. Black Hole

    Black Hole May contain traces of nut


    Correct, auto-created folders are restricted to the first level.

    My modus operandum is to flatten as a rule, but when I want a series captured in its own folder I pre-create the folder and mark it not for flattening.
  6. prpr

    prpr Well-Known Member

    "As far as I'm aware"
  7. Black Hole

    Black Hole May contain traces of nut

    Aha - an initialism containing a contraction! "AFAIK" is more conventional.
  8. prpr

    prpr Well-Known Member

    Would it have been better as AFAIAA or would that have similarly confused?

    You are obviously welcome to operate your machine how you like, but it seems to me that if the machine automatically creates folders to put recording in, then it should automatically delete them again when you remove the recording.
    Seems odd to me to have to delete the empty folder as a separate step every time. It's dull and tedious and computers are much better at doing that sort of rubbish than humans.
  9. Ezra Pound

    Ezra Pound Well-Known Member

    Yes, it can be quite useful to determine whether the package has been installed via the web-if or locally
  10. Black Hole

    Black Hole May contain traces of nut

    What's wrong with "AFAIK"? It's in common circulation and in general readers don't have to guess what it means. As an aside, the phrase "to my knowledge" sometimes gets used when the speaker means "as far as I know", but could be interpreted as "I definitely know" - not the same thing!

    Please do not regard my comments as dismissive, all contributions are welcome and flatten certainly doesn't suit everyone. The last recording in a folder and the folder itself can be deleted in one go by stepping back and deleting the folder, but that requires discipline. Your tidy-folders package will get a shake-down - what happens of there is no .ts but there is a .mpg, for example? Does it ignore any folder starting with "["?
  11. prpr

    prpr Well-Known Member

    No dismissive-ness taken! I presume deleting the folder from the higher level will delete anything and everything in it regardless, and not only if it contains a single recording? It seems to me that taking this approach could lead to more errors with deleting things you didn't mean to. Much better IMHO (hope you get that one!) just to delete the recording like you would any other and let the machine take care of the housekeeping.

    To answer your questions:
    If there is no .ts but there is a .mpg (or indeed anything else) then they will get deleted. This is where it starts to get tricky I guess. What other files should it be looking for to decide whether a folder is empty or not? .mpg and .mp3 ? Or should it just take anything which doesn't start with a '.'?
    It only special cases the dustbin folder (if you have the Undelete package installed). The name of it is irrelevant - it looks it up from what you configured in the web interface.
  12. Luke

    Luke Well-Knwon Member

    Would it delete a folder containing just other folders themselves containing recordings?
  13. Black Hole

    Black Hole May contain traces of nut

    We have developed a convention that any folders "[...]" (implemented as anything starting "[") should be untouched, this package should do the same. If an undelete folder exists, perhaps tidy-folders should be deleting by moving things into it?

    As to what counts as an empty folder, I say an empty folder! I think there might be a .series file that hangs around or something, but other than that why disregard anything?
  14. prpr

    prpr Well-Known Member

  15. prpr

    prpr Well-Known Member

    That's easy enough to do.

    No, the whole point is that it shouldn't be "deleting" anything. It is only cleaning up the folder and any hidden flag files. There is no point moving an empty folder to the bin is there?

    Yes, and .autodecrypt and .autoshrink and .noflatten and...
    ... which is why I suggested anything not starting with '.'
  16. Black Hole

    Black Hole May contain traces of nut

    I'm not sure about that. For example, if a flatten user has set up a series folder for no-flatten, the last thing he would want is the folder disappearing having caught up with the series so far. The next recording would recreate the folder, and then it would get flattened. Some of us have special purpose folders (eg marked Autoshrink) that we can drop a file into to process and then move it out again when done - granted we could use [] but the .autoshrink is a clue - don't delete!

    The undelete option provides a safety net - particularly before a process is debugged - so that anything that does get accidentally deleted or as a mistake in the processing can be recovered. The whole folder can go in there and then either rescued or timed out.
  17. af123

    af123 Administrator Staff Member

    I think to make this package suitable for inclusion in the main package repository it must at least only remove folders that contain only . files - I have a lot of folders that just contain AVI or MP4 files (mostly recordings I converted over from my last PVR) and that isn't uncommon.

    If I was writing it in shell or Jim I'd do something like this:

    for folder in "$mediaroot/"*; do
        if [`ls -1 "$folder" | wc -l` -eq 0 ]; then
            rm "$folder/."*
            rmdir $folder
    It would actually be easier in Jim because the box has libraries that automatically determine the media root (different on the HD model). The key point is that when it thinks a folder is eligible it removes the . files and then removes the folder. If in the meantime something has appeared in there then the subsequent rmdir call will fail (non empty directory error).
  18. Ezra Pound

    Ezra Pound Well-Known Member

    I have not installed tidy-folders_1.0.0_mipsel.opk but I think there would be a problem uninstalling it as the postinst and the prerm files are the same
  19. prpr

    prpr Well-Known Member

    Damnation. How did that happen? I must have screwed up a "cp" command somewhere :(
  20. prpr

    prpr Well-Known Member

    I can't think you would want flatten and tidy-folders installed together. They seem mutually exclusive to my mind.