Page 1 of 1

Generic rename

Posted: 05 Jan 2020, 00:10
by devster
I would like to start using FileBot for stuff other than media files.
I'm trying a very basic attempt with software.
This is the command:

Code: Select all

$ filebot -rename --db file --action test software/ --format '{if (f.isDirectory()) {"cephfs-directory/$fn"} else {"cephfs/$fn"}}'
However the output is surprising:

Code: Select all

$ ls -1F software/
Dash.dmg
Parallels Desktop/

$ filebot -rename --db file --action testsoftware/ --format '{if (f.isDirectory()) {"cephfs-directory/$fn"} else {"/cephfs/$fn"}}'
Rename files using [Plain File]
[TEST] from [software/Dash_5.0.2.dmg] to [/cephfs/Dash.dmg]
Processed 1 files
I'm unable to figure out why it's seemingly skipping directories.
Intended usage would be a keeplink with files and a keeplink with entire directories.

Code: Select all

# artificial output I would like
$ stat -c '%N' software/*
Dash.dmg -> /cephfs/software/Dash.dmg
Parallels Desktop/ -> /cephfs/software/Parallels Desktop/

Re: Generic rename

Posted: 05 Jan 2020, 10:30
by rednoah
FileBot does not work on directories. FileBot works on files. You can re-organized files into new directories, but you can't directly process directories, since FileBot will always process the files inside those directories, if you pass a directory as input argument.

:idea: I suppose you could do -rename -r to process all files from all sub directories, and then decide where each file needs to go, e.g. based on how many folder levels the file path has. But you won't be able to symlink directories either. You'll just end up with a symlink for each file.

Re: Generic rename

Posted: 05 Jan 2020, 17:14
by devster
I see.
Is there a way to script that? I see in the amc.groovy script the test for a directory exists, but from what I see is only to scan for files inside it.

Re: Generic rename

Posted: 06 Jan 2020, 00:17
by rednoah
The amc script has its own way of interpreting input arguments, i.e. to convert one or more input folders into a list of files.

As for scripting, you can check the number of parents folders for a given file with code like this:

Code: Select all

f.listPath().count{ it.directory }