Generic rename

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
devster
Posts: 388
Joined: 06 Jun 2017, 22:56

Generic rename

Post 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/
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 19128
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Generic rename

Post 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.
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 388
Joined: 06 Jun 2017, 22:56

Re: Generic rename

Post 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.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 19128
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Generic rename

Post 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 }
:idea: Please read the FAQ and How to Request Help.
Post Reply