Page 1 of 1

Override existing file - different extension

Posted: 19 May 2016, 15:52
by Achandab
Is it possible for the override command to overwrite existing file if the extension is different? At the moment when AMC is importing movie file i seem to have duplicates of the files with different extensions

Example

Gladiator\Gladiator.mvk
Gladiator\Gladiator.mp4
Gladiator\Gladiator..avi

I only wish to have one copy, preferably the latest and largest file size. I thought override handled this?

Re: Override existing file - different extension

Posted: 19 May 2016, 16:11
by rednoah
1.
I thought override handled this?
The amc script does not support those kind of "duplicate" checks. Conflict behaviour doesn't come into play if the file path is different.


2.
I only wish to have one copy, preferably the latest and largest file size.
That might be conceivable as a separate script that detects and delete semantic duplicates.

Re: Override existing file - different extension

Posted: 19 May 2016, 22:49
by Achandab
Ah okay, so override only works if the file extension is the same?

Is this script something you are looking at developing? At the moment im using a file duplicator software to manually remove them each time

Re: Override existing file - different extension

Posted: 20 May 2016, 05:35
by rednoah
I guess this is already half of the solution:

Code: Select all

args.getFiles{ it.isVideo() }.groupBy{ it.metadata }.each{ m, fs ->
   println "$m => $fs.name"
}
Just add a few more lines to select the one you want, and the delete the others.

@see viewtopic.php?f=8&t=3791#p21206

Re: Override existing file - different extension

Posted: 20 May 2016, 05:53
by rednoah
You can play with something like this and see if it works for you:

Code: Select all

def args = '/Users/reinhard/Development/test/OUTPUT' as File

args.getFiles{ it.isVideo() }.groupBy{ it.metadata }.each{ m, fs ->
	if (fs.size() > 1) {
		println m
		fs.toSorted(new VideoQuality()).eachWithIndex{ f, i ->
			if (i == 0) {
				println "[+] 1. $f"
			} else {
				println "[-] ${i+1}. $f"
				// f.delete()
			}
		}
	}
}

Re: Override existing file - different extension

Posted: 20 May 2016, 09:06
by Achandab
Cheers mate, will have a go

Re: Override existing file - different extension

Posted: 20 May 2016, 09:25
by rednoah
Here's the other thread with the same issue: viewtopic.php?t=3791

Re: Override existing file - different extension

Posted: 20 May 2016, 14:14
by Achandab
thanks again!

Re: Override existing file - different extension

Posted: 19 Mar 2024, 17:32
by crunchypancake
In case it could be helpful for anybody else, this is a simple post-processing script I am using to delete duplicates, in cases where the --action replace doesn't cut it.

Groovy: Select all

{ source, target, metadata ->
    def fileName = target.nameWithoutExtension
    target.dir.listFiles { file ->
        file != target && file.video && file.nameWithoutExtension == fileName
    }.each { fileToDelete ->
        trash(fileToDelete)
    }
}
This is only for absolute overriding and doesn't do any quality checks whatsoever.

Below is a sample output from using the script.

Console Output: Select all

Lookup via [Westworld] [Westworld]
Fetching episode data for [Westworld]
* Westworld [296762] | 36 episodes | 1x01-10 .. 2x01-10 .. 3x01-08 .. 4x01-08
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E01.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E01 - The Auguries.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E02.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E02 - Well Enough Alone.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E03.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E03 - Années Folles.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E04.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E04 - Generation Loss.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E05.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E05 - Zhuangzi.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E06.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E06 - Fidelity.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E07.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E07 - Metanoia.mp4]
[MOVE] from [/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG/Westworld.S04E08.1080p.BluRay.x265-RARBG.mp4] to [/library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E08 - Que Será, Será.mp4]
[CLEAN] Delete clutter files (/library/downloads/complete/Westworld.S04.1080p.BluRay.x265-RARBG)
[SCRIPT] Run Script (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E01 - The Auguries.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E02 - Well Enough Alone.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E03 - Années Folles.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E04 - Generation Loss.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E05 - Zhuangzi.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E06 - Fidelity.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E07 - Metanoia.mkv (remove-duplicates.groovy)
[SCRIPT] TRASH /library/library/shows/Westworld (2016)/Season 04/Westworld (2016) - S04E08 - Que Será, Será.mkv (remove-duplicates.groovy)
Processed 8 files

Re: Override existing file - different extension

Posted: 19 Mar 2024, 18:03
by rednoah