[DOCS] Custom Rename Action

Running FileBot from the console, Groovy scripting, shell scripts, etc
Locked
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[DOCS] Custom Rename Action

Post by rednoah »

Standard Actions:
  • MOVE
  • COPY (i.e. copy-on-write clone if possible, or copy if necessary)
  • SYMLINK (i.e. create relative symlink)
  • HARDLINK
  • KEEPLINK (i.e. move file and create a relative symlink to the new path in its place)
  • DUPLICATE (i.e. hardlink if possible, or copy-on-write clone if possible, or copy if necessary)
  • CLONE (i.e. copy-on-write clone)
  • TEST (i.e. do nothing)

e.g. process files with --action test to do a dry run:

Shell: Select all

--action TEST



Shell Actions:
The --action parameter accepts custom executables as parameter value. The source path and the target path are passed as first and second argument respectively.

e.g. use a custom shell script perform arbitrary operations:

Shell: Select all

--action /usr/local/bin/echo-arguments

Shell: Select all

#!/bin/sh -xu
echo "SOURCE=$1"
echo "TARGET=$2"
e.g. use scp to copy files to a remote server:

Shell: Select all

--action /usr/local/bin/scp-to-server

Shell: Select all

#!/bin/sh -xu
scp -v "$1" "user@host:/volume1/files/$2"
e.g. use ln -s to create absolute symlinks:

Shell: Select all

--action /usr/local/bin/create-absolute-symlink

Shell: Select all

#!/bin/sh -xu
mkdir -p "$(dirname "$2")"
ln -sv "$1" "$2"



Groovy Actions:
The --action parameter accepts custom Groovy code as parameter value. The code is expected to define a Function(File, File) that returns either null or a File object that represents the final target path.

e.g. just print the source and target file path:

Shell: Select all

--action '{ from, to -> println "$from => $to" }'
:idea: Please read the FAQ and How to Request Help.
Locked