Page 1 of 1

New to CLI/Scripts, need some help.

Posted: 05 Oct 2016, 03:09
by Crankrune
I have a few questions about this, I've searched and not found what I need.

1. Basic question, does the command line look in subfolders? As in if I direct it to "H:\TV\Unsorted\" will it look in and rename in "H:\TV\Unsorted\TV Show Download Folder\"?

2. I'm having issues with a command I've been trying not sure exactly why. This is the full command.

Code: Select all

filebot -rename "H:/TV/.Unsorted/" --format "{norm = {it.replaceAll(/[`´‘’ʻ]/, "'").replace("?", "!").replace('"', "''").replace(':', " -").replace('/',' - ').replacePart(' [Part $1]')};''}{file.path[0]}:\TV\{csv('H:/TV/Names.csv').get(n.replaceTrailingBrackets("").replace(':', " -")) ?: n.replaceTrailingBrackets("").replace(':', " -")}\{'Season '+s}{((file.path[0..5]+norm(n)+'/Season '+s) as File).exists() ? '' : ' '+[vf.match(/720[pP]|1080[pP]/)]}\{episode.special ? 'Special '+special.pad(2) : 'Episode '+es*.pad(2).join('-')} - {episode.special ? norm(t) : norm(episode.title.toString())}{' [' + fn.matchAll(/extended|unaired.pilot|leaked.pilot|unaired.episode|unaired|unsold.pilot/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, " ") + ']'}{((file.path[0..5]+norm(n)+'/Season '+s) as File).exists() ? ' '+[vf.match(/720[pP]|1080[pP]/)] : ''}{' '+[vc.match(/HEVC|x265/)]}"
I run this and get his back "'1080[pP]' is not recognized as an internal or external command, operable program or batch file." I have the format quoted, so I'm not sure why it's taking this part out of it.

3. How do I create a script? And do I have to do anything to format to make it work in a script?

4. I read and believe it's not possible but, can use CLI/Scripts to rename "Generic Files"?

I'm sorry if these are dumb questions, please and thanks for any help.

Re: New to CLI/Scripts, need some help.

Posted: 05 Oct 2016, 04:56
by rednoah
1.
Just use the amc script and force TV mode (or read filebot -help).

2.
Just use @files to pass complex arguments (or learn how to escape arguments correctly).

3.
No, and No.

4.
No. There's plenty of command-line tools that do exactly that.


EDIT:

r4347 allows you to do "Generic Files" processing by calling -rename --db xattr -non-strict on non-xattr-tagged files.

Re: New to CLI/Scripts, need some help.

Posted: 06 Oct 2016, 04:23
by Crankrune
Thanks, I've starting to figure out the command line, though I've had a problem with my first script/command. It won't look in subfolders, which is annoying since that's where most things download to. I know you mention the AMC script, but I already have my preferred format.

Here's the command in question.

Code: Select all

filebot -rename "H:/TV/.Unsorted/" --def @/FileBotScripts/Chicagoverse.txt --output "H:/TV/!Playlists/Chicagoverse" --action hardlink --filter "n.matches(/Chicago P.D.|Chicago Fire|Chicago Med/)"
Also, it doesn't seem possible to just let the output be determined by my format like in the GUI. Anyway around that?

Re: New to CLI/Scripts, need some help.

Posted: 06 Oct 2016, 04:35
by rednoah
1.
If you use -rename calls then you must use the --format option to pass in your format. You should also add --db TheTVDB to force TV mode.

If you use the amc script then --format is ignored in favour of the --def ***Format options. So either way, you can use your own formats.


2.
The -r option allows you to process folders recursively:

Code: Select all

filebot -help

Code: Select all

-r                                     : Resolve folders recursively
Note that calling -rename -r on a folder is not the same as calling the amc script on a folder. The amc script is likely to work significantly better in tricky corner-cases.


PS: The --def options are only used by the amc script, so you're already getting confused, and might as well stick to the amc script all the way. ;)

Re: New to CLI/Scripts, need some help.

Posted: 06 Oct 2016, 05:00
by Crankrune
Thanks again, I only used --def because that's what I saw in the post about @files, I see now that's not necessary. I also added the db to it, I had just forgot. Where do I get the "r4347" file? The sourceforge page didn't have that one yet. Also, is there inverse to -r to make sure something doesn't look in subfolders?

Re: New to CLI/Scripts, need some help.

Posted: 06 Oct 2016, 11:08
by rednoah
1.
I've uploaded a new build for you.

2.
FileBot won't look into subfolders by default unless -r is specified. Scripts (e.g. amc, suball, etc) do whatever they want which is usually some kind of recursive file search. If you pass files instead of folders then you decide exactly which files are processed regardless of where they are.

Re: New to CLI/Scripts, need some help.

Posted: 06 Oct 2016, 16:58
by Crankrune
I ran this command. No script, no -r, and it searched in the subfolders, which I didn't want it to do. How can I change that? Also, how do I revert just the last thing in the command line? I used the revert command, it asked me to specify a folder, so I did, and it reverted things I renamed months ago. And anyway way to undo a revert?

Code: Select all

filebot -rename "F:/TV/YouTube Series/Downloads+/" --db xattr -non-strict --format @/FileBotScripts/YouTubeFormat.txt

Re: New to CLI/Scripts, need some help.

Posted: 06 Oct 2016, 18:16
by rednoah
1.
When testing, use --action test to do a dry-run. Once you know what you're doing, you can switch to --action move (default).


2.
Nope, it most definitely will only process files in the given folder, and if you claim anything else you better have some solid proof and a test case (i.e. command-line logs). ;)

PROOF:

Code: Select all

$ find . -type f
./test/Avatar.mp4

$ filebot -rename . --db TheMovieDB -non-strict
Rename movies using [TheMovieDB]
No media files: []

$ filebot -rename -r . --db TheMovieDB -non-strict
Rename movies using [TheMovieDB]
[MOVE] Rename [test/Avatar.mp4] to [test/Avatar (2009).mp4]

3.
You cannot just revert the last rename operation. You cannot revert a revert operation. You can revert files by passing in the original or current file path or parent folder.