@file syntax for reading cmdline args from text files

How-to guides, frequently asked questions, not-so-obvious features, etc
Post Reply
User avatar
rednoah
The Source
Posts: 12354
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

@file syntax for reading cmdline args from text files

Post by rednoah » 07 Dec 2015, 07:17

Passing complex arguments that contain lots of special characters like $!%'" to a command-line tool can be tricky. Correctly escaping such arguments for cmd or bash can get very painful very quickly.


Argument Files:

FileBot allows you specify argument files via @/path/to/file syntax, so you can pass in your complex command-line arguments via separate text files line by line without having to worry about quoting or escaping anything.

e.g. @file usage

Code: Select all

filebot -script fn:amc /input --output /output --def @/path/to/args.txt
e.g. /path/to/args.txt

Code: Select all

movieFormat=Movies/{ny}/{fn}
seriesFormat=TV/{n}/{'S'+s}/{fn}
animeFormat=Anime/{n}/{fn}
Notes:
  • Argument files must not contain byte order marks (i.e. do not use Microsoft tools for editing text files)
  • Argument files are read with the default encoding (i.e. CP1252 on Windows, UTF-8 on Linux and Mac)
:!: DO NOT use Microsoft tools such as Notepad or Word to edit plain text files. Use proper tools such as Notepad++ or Sublime Text instead.



Binding Value:

You may also pass --def script binding values via UTF-8 encoded text files. That's handy when passing in complex multi-line formats.

e.g. --def [email protected] usage

Code: Select all

filebot -script fn:amc /input --output /output --def [email protected]/path/to/MovieFormat.groovy
e.g. /path/to/MovieFormat.groovy

Code: Select all

Movies/{
[ allOf {ny}
        { allOf {vf}
                {group}
        }
, allOf {ny}
        {'CD'+pi}
        {lang}
]*.findResults { 
    if (it) it.toString()
              .replaceAll(/[!?.]+$/)
              .asciiQuotes()
}*.join(' ')
  .join('/')
}
My (very excellent) support depends on Windows Store and Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest