whyboris / Video-Hub-App

Official repository for Video Hub App
https://videohubapp.com
MIT License
568 stars 174 forks source link

Folder flattening #352

Open danjool opened 4 years ago

danjool commented 4 years ago

Potentially valuable to seem to streamline some of their media library flattening the contents of a chosen folder -- moving all the media contents of that target folder's subfolders to the target folder.

flatten-folder-before-after

https://github.com/whyboris/Video-Hub-App/pull/351 (ONLY TESTED IN WIN10) Demonstrates this by adding a right click context menu to the folder, replicating the context menu for media files but only supplying a Flatten command. If this feature were approved, implemented this way, I'd expect a few other folder commands would make sense as well.

Two design questions: Q1: In a typical filesystem context I would take that to mean all subfolder contents bubble up to the target folder, and the now useless subfolders are removed. In the context of VHA, that seems like over reach, in that the user would be deleting things they can't see, the non media files and the subfolders without media files. Does that seem right?

Q2: I'm torn on how the user should be able to engage this action. The way I implemented it is that all subfolders of the target folder a user clicks on bubble up, the target folder stays where it is. An alternative, plausible user expectation that the target folder itself would also bubble its contents up to the current folder.

whyboris commented 4 years ago

Thank you for the discussion and for the PR #351 🙌

I'll give the code you propose a try and see how it feels. I agree with you that VHA restructuring all the folders would be an "over reach".

I'm unsure yet about the functionality: I do like that VHA provides a faithful representation of what the folder structure is, but this flattening is definitely useful in some situations. My immediate concern is all the code complexity and questions that need to be answered with code (for example, what happens if users add more files into the subfolders and re-scan, etc).

I'll comment again after I try it out 👍

danjool commented 4 years ago

My expectation would be that if I flatten contents out of some subfolders, then manually add media content to one of those subfolders, and rescan; then the subfolder that became invisible/irrelevent to VHA once again becomes relevant.

Pretty sure that's what happens based on my testing.

The code should mostly be as good as your code, cause its mostly your code from getVideoPathsAndNames rejiggered. So much so that if there were a third function that used readdirSync, it would probably make sense to refactor getVideoPathsAndNames, flattenFolder, and that third hypothetical as callbacks that get passed to a generic folder walker.

cal2195 commented 4 years ago

Just leaving my thoughts here: 😄

I appreciate the work here, although I'm not sure it fits within VHA - this seems more like an idea for a script, eg.

for file in subfolderfiles:
    mv file .

Even deleting files in VHA only moves them to the trash - there's a lot of headache dealing with filesystem errors that'd I'd rather not deal with! 😓 Like, what happens if two files are now the same name, trying to move to the same folder..?

On the other hand - flattening a file system is really useful sometimes, but I think we should implement it in the way things like ranger implement it - that is, don't change the file system, but only change the view in VHA.

This should be extremely easy to implement in VHA, and is probably already possible to do manually (just filter all results by a prefix folder path). This would allow the exact same view as above, just without touching the actual filesystem. I feel this lines up much better with VHA's existing feature set of fast filtering. This, paired with something like #315 would be extremely cool!

I'm open to being convinced otherwise, but I'm curious what you'd think about this solution @danjool?

cal2195 commented 4 years ago

(Btw, +1 for having screenshots for all the features you implement! 👍 )

whyboris commented 4 years ago

Quick comment: when you're not in folder view, everything is already 'flattened'. And if you search for the folder name you want to 'flatten' -- the gallery will show everything 'flattened'. So we might not need to have any extra functionality?

cal2195 commented 4 years ago

Quick comment: when you're not in folder view, everything is already 'flattened'. And if you search for the folder name you want to 'flatten' -- the gallery will show everything 'flattened'. So we might not need to have any extra functionality?

This is true, but I wouldn't say no to a right click menu item to do it for me! 😊 Also, it would need to only show this folder, not folders by the same name elsewhere!👍

danjool commented 4 years ago

Here's my counter use case: A user has a bunch of video files scattered across a chaotic, sometimes deep folder structure. They want to do something to those some of those videos other than opening them one at a time, eg queue them up from handbrake processing. So the user has three things to do: Determine which files need processing, get a list of paths, and process them.

VHA already handles the first task well.
Flattening the contents answers the where by changing the answer to be trivial. The processing was always easy if the files to be queued are already consolidated.

I don't know of any combination of software that meets this need.

The flattened contents aren't the goal, just a means to an end. But the end is generic. Its kinda like what I really want is a universal export of full paths of a subset of a hub's contents. But the only format for such an export I can reasonably expect other applications to respect is folders.

The alternative of the script for flattening isn't selective enough for task 1. The alternative of just representing the files as flattened through VHA's View Folder feature doesn't hand you the output to be used generically for task 3.

That said, I do think of a stance of "VHA doesn't mess with the actual files" is an intuitive and valid choice. But it is a choice that suggests the Delete action is not an appropriate feature. I was probably going to hold off on suggesting Flattening until I saw the addition of Delete, as that feature indicated to me that VHA was breaking the filesystem seal.

whyboris commented 4 years ago

Thank you for the comment 👍

I added "delete file" somewhat reluctantly, but I see how useful it is (at least when searching for duplicates). I made sure to put the feature behind a toggle, so it's not there unless a user explicitly wants it and toggles it.

I could see VHA taking on more roles; perhaps similarly hidden behind toggles so you can't accidentally move files around the file system.

I too want some simple way to flatten a folder sometimes; I wish we didn't have to resort to making VHA do it 😅

I'll think about all this more over the weekend.

whyboris commented 4 years ago

@danjool -- you say this:

what I really want is a universal export of full paths of a subset of a hub's contents

It sounds like that functionality may get you what you want without flattening a folder. What if you can grab the list of paths all the currently-showing videos (as a bonus: in whatever order they are showing) and save it to clipboard?

I've only imagined this app as being used for randomly clicking around a collection of videos, that I don't realize there may be many other uses.

Someone emailed me previously and requested a way to get the path to the video, so I added that feature to the 'details' view 🤷‍♂ 😁

Would a simple export of the paths to all the visible videos be good enough without adding the flattening feature?

danjool commented 4 years ago

Q: Would a simple export of the paths to all the visible videos be good enough without adding the flattening feature?

Not really? The list of paths was just a way of picturing the intermediate goal, where the ultimate goal is the bulk use of VHA's organization by another application. I can think of many formats that VHA could export to, but there aren't any universal formats for importing -- I can't expect any random application we might want to export to to actually respect any of those formats.

Except for files in folders. It is reasonable to think that many other applications can understand files-in-folders as a format for conveying, "hey do what you do but with all these files".

It is also reasonable to think that a moderate computer user could take advantage of this, but not be able to use a more custom format for export. A programmer could probably figure it out, but designing for programmers is probably an anti-pattern!

whyboris commented 4 years ago

I finally found an external program that will flatten folders: https://alternativeto.net/software/suction/ Review and download link here: https://www.ghacks.net/2009/06/09/consolidate-files-with-suction/

I can't find a GitHub for it -- it's not been updated since ~2010 and the official website no longer exists 😢 but the software works beautifully 🎉

dia3olik commented 3 years ago

This would be solved with the simple addition of move to, then the user can simply select all the files in the subfolder(s) and then move to a new one or the folder above ;-)