-
-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create categories only by the top level subfolder #686
Comments
The current Implementing this issue would probably require a variant of the algorithm, using |
I made some changes to FolderToCat.pm and it works well for me. ...
parameters =>
- [ { type => "bool", desc => "Delete all your static categories before creating the ones matching your subfolders" } ]
+ [ { type => "bool", desc => "Delete all your static categories before creating the ones matching your subfolders" },
+ { type => "bool", desc => "Create categories by the top level subfolder" }]
...
shift;
my $lrr_info = shift;
- my ($delete_old_cats) = @_;
+ my ($delete_old_cats, $by_top_folder) = @_;
my $logger = get_logger( "Folder2Category", "plugins" );
my $userdir = LANraragi::Model::Config->get_userdir;
my %subfolders;
my @created_categories;
+ my $dirname;
...
find(
{ wanted => sub {
return if $File::Find::dir eq $userdir; # Direct children of the content dir are excluded
-
- my $dirname = basename($File::Find::dir);
+ if (not($by_top_folder)) {
+ $dirname = basename($File::Find::dir);
+ }
if ( is_archive($_) ) {
unless ( exists( $subfolders{$dirname} ) ) {
$subfolders{$dirname} = []; # Create array in hash for this folder
}
push @{ $subfolders{$dirname} }, $_;
}
+ elsif ($by_top_folder) {
+ $dirname = basename($File::Find::dir);
+ }
},
no_chdir => 1,
follow_fast => 1
},
$userdir
); You can download the file from here. |
That doesn't seem to work in all cases -- I believe this code would end up creating one single category named after the deepest subfolder. It did give me a simple idea for doing this without |
Please describe your suggestion, and the problem it'd solve.
When using the "Subfolders to Categories" script, an option to create them only by the top folders would be great to separate content by origin.
With the current behavior a category would be created for "F1, F2 .. F9", my proposition would be to be able to choose between that or to create categories only for the top level "D11, D12, D13 and D14".
In my own gallery I currently have a folder for site1 and another for site2, in one of those, the files are stored in separated folders by authors, in the other one, all of them are just there. This produces an inconsistent set of tags that quickly becomes unusable and unmanageable when you have hundreds/thousands of files/folders.
The text was updated successfully, but these errors were encountered: