[DOCS] --conflict resolution for duplicate file paths

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

[DOCS] --conflict resolution for duplicate file paths

Post by rednoah »

The --conflict option allows you to specify what happens when a file cannot be processed because the destination path already exists.


Conflict Options:

  • SKIP (skip existing files)
  • OVERRIDE (replace existing files)
  • AUTO (replace the existing file if the new file is better)
  • INDEX (add index and keep both files)
  • FAIL (fail and quit)



--conflict SKIP ... skip files where the destination file paths already exists (default behaviour if --conflict is left unspecified)

Console Output: Select all

$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict SKIP
Skipped [Avatar.2009.mp4] because [Avatar (2009).mp4] already exists

--conflict OVERRIDE ... process files even if the destination file path already exists and replace the existing file (i.e. delete and overwrite)

Console Output: Select all

$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict OVERRIDE
[MOVE] from [Avatar.2009.mp4] to [Avatar (2009).mp4]

--conflict AUTO ... process files even if the destination file path already exists and replace the existing file (i.e. delete and overwrite) but only if the new file is better (i.e. higher resolution, better video codec, higher bitrate, larger file size, etc) than the old file

Console Output: Select all

$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict AUTO
[MOVE] from [Avatar.2009.mp4] to [Avatar (2009).mp4]
$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict AUTO
Skipped [Avatar.2009.mp4] because [Avatar (2009).mp4] already exists

--conflict INDEX ... add .1 .2 .3 etc to the destination file path if necessary so that the given file can be processed

Console Output: Select all

$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict INDEX
[MOVE] from [Avatar.2009.mp4] to [Avatar (2009).mp4]
$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict INDEX
[MOVE] from [Avatar.2009.mp4] to [Avatar (2009).1.mp4]

--conflict FAIL ... fail and stop processing files once a file cannot be processed

Console Output: Select all

$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --log INFO --conflict FAIL
Failed to process [Avatar.2009.mp4] because [Avatar (2009).mp4] already exists



Custom Conflict Actions:

The --conflict parameter accepts custom Groovy code as parameter value. The code is expected to define a Function(File, File) that returns either null (e.g. skip behaviour) or a File object that either confirms (e.g. replace behaviour) or changes (e.g. index behaviour) the target path.


e.g. replace target file but only if the source file is larger:

Shell: Select all

--action '{ from, to -> from.length() > to.length() ? to : null }'

e.g. index target file with (2) (3) (4) etc:

Shell: Select all

--conflict /path/to/Index2.groovy

Groovy: Select all

{ from, to ->
	(2..99).findResult{ i ->
		def f = to % " ($i)"
		return f.exists() ? null : f
	}
}
:idea: Please read the FAQ and How to Request Help.
Post Reply