@file syntax for reading cmdline args from text files

How-to guides, frequently asked questions, not-so-obvious features, etc
User avatar
rednoah
The Source
Posts: 11151
Location: Taipei
Contact:

@file syntax for reading cmdline args from text files

Postby 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.

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)



You may also pass --def script binding values via 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 movieFormat=@/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:

Return to “Tips, Tricks and Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest