batch file help with sub directories

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
themezz
Posts: 15
Joined: 19 Mar 2021, 16:58

batch file help with sub directories

Post by themezz »

filebot -rename -r K:\INBOUND5\*.mkv --db TheTVDB -non-strict

This fails to process subdirectories under INBOUND5 directory
Shouldn't the -r switch trigger that behavior?
What did I miss?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: batch file help with sub directories

Post by rednoah »

-r has no effect if you're passing a list of files as input arguments.

:idea: If you type *.mkv then the shell will expand that to all the files, and then pass a list of files as input arguments. The command you call can't know if you did *.mkv or typed all the file names one by one.

:arrow: You'll need to pass the folder as input. And if you want to only process mkv files then you need to use the --file-filter option.

:arrow: Alternatively, you can do find -exec to find all the mkv files from folder hierarchy and then pass them in to the filebot command as input arguments. This is easy on Linux, maybe not so much if you're using Windows.
:idea: Please read the FAQ and How to Request Help.
themezz
Posts: 15
Joined: 19 Mar 2021, 16:58

Re: batch file help with sub directories

Post by themezz »

Honestly I appreciate the reply but I do not understand it.
-r has no effect if you're passing a list of files as input arguments.
But I am not passing a list of files. Just using this K:\INBOUND5\*.mkv
If you type *.mkv then the shell will expand that to all the files, and then pass a list of files as input arguments. The command you call can't know if you did *.mkv or typed all the file names one by one.
excuse my inexperience, but I do not really grasp that
You'll need to pass the folder as input.
The folder names change depends on what gets downloaded. I just want to process all subfolders no matter what the folders are named.

Alternatively, you can do find -exec to find all the mkv files from folder hierarchy and then pass them in to the filebot command as input arguments. This is easy on Linux, maybe not so much if you're using Windows.
I am using Windows 10.

So maybe I have to use find -exec to process all the files in all the subfolders.

I realize you are trying to educate me and I appreciate it, but what do I have to change in this line:

filebot -rename -r K:\INBOUND5\*.mkv --db TheTVDB -non-strict

To have all mkv files under K:\INBOUND5\ processed by filebot

Example

I have filebot to process

K:\INBOUND5\show1\*.mkv
K:\INBOUND5\show1\season1\*.mkv
K:\INBOUND5\show1\season2\*.mkv
K:\INBOUND5\show1\season3\*.mkv
K:\INBOUND5\show2\*.mkv
K:\INBOUND5\show2\*.mkv
K:\INBOUND5\show3\*.mkv

But the folder names will be different every day

So I want to process all mkv files under K:\INBOUND5\ no matter where they are

Same way del *.txt /s deletes all txt files no matter where they are

Thanks for your time and reply.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: batch file help with sub directories

Post by rednoah »

e.g. pass K:\INBOUNDS as first input argument and then have FileBot select all the *.mkv files for processing:

Code: Select all

filebot -rename -r "K:\INBOUND5" --file-filter "ext == /mkv/" --db TheTVDB -non-strict


:!: :!: :!: That's a most interesting observation. That shouldn't work, but del is a CMD built-in (and not an executable) so it just works differently I suppose. Windows CMD really never ceases to amaze what what a dumpster fire it is... :lol:
themezz wrote: 11 Jun 2022, 20:52 Same way del *.txt /s deletes all txt files no matter where they are


:idea: Correctly understanding * shell expansion is useful though, because it's universal applicable to all command-line tools on all operating systems. You can use the sysenv script to just mirror the arguments you pass in, so you can compare and contrast and get a feel for how it works:

Code: Select all

filebot -script fn:sysenv K:\INBOUND5

Code: Select all

filebot -script fn:sysenv K:\INBOUND5\A.mkv K:\INBOUND5\B.mkv K:\INBOUND5\C.mkv

Code: Select all

filebot -script fn:sysenv K:\INBOUND5\*.mkv
:idea: Please read the FAQ and How to Request Help.
themezz
Posts: 15
Joined: 19 Mar 2021, 16:58

Re: batch file help with sub directories

Post by themezz »

K:\INBOUNDS as first input argument and then have FileBot select all the *.mkv files for processing:
thank you
Windows CMD really never ceases to amaze what what a dumpster fire it is.
That's for sure and each upgrade of Win gets worse on many levels.

I use Linux Mint on my main computer, It's an old laptop that runs faster than my Windows newer machine. (Both SSD)
Correctly understanding * shell expansion is useful though, because it's universal applicable to all command-line tools on all operating systems.
Thank you, I have never ran across that before, but now that I have a use for it I will read now. Appreciate your help and your time
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: batch file help with sub directories

Post by rednoah »

themezz wrote: 12 Jun 2022, 17:19
Windows CMD really never ceases to amaze what what a dumpster fire it is.
That's for sure and each upgrade of Win gets worse on many levels.
That one has been around and unchanged for 30+ years though probably. :D I can totally see how adding recursive delete to the del built-in function made sense to some MS product manager though. It's highly inconsistent, but kinda convenient to have. Because how else would you do that on Windows CMD? :D You'd need find -delete on Unix, because rm -r *.mkv certainly won't do a recursive delete of mkv files. :lol:
:idea: Please read the FAQ and How to Request Help.
themezz
Posts: 15
Joined: 19 Mar 2021, 16:58

Re: batch file help with sub directories

Post by themezz »

When this hard drive dies I will switch to Linus Mint for my plex "server" :geek:
Post Reply