Page 1 of 1

Making amc copy unmatched files

Posted: 24 Mar 2014, 07:06
by gimmeth
I would like the amc script to copy music files to the destination folder even if a match is not found in Acoustdb. I tried to add this logic in myself, but I don't think I understand the script well enough. I'd appreciate any insight.

Code: Select all


	// MUSIC MODE
	if (group.music) {
		def dest = rename(file:files, format:format.music, db:'AcoustID')
		if (dest == null && failOnError) {
			throw new Exception("Failed to rename music: $group.music")
			// Start my code (does not work)
			File file = new File(files);  
			File dir = new File(format.music);  
			boolean fileMoved = file.renameTo(new File(dir, file.getName()));
		}
	}


Re: Making amc copy unmatched files

Posted: 24 Mar 2014, 07:50
by rednoah
I would make any changes only at the very end of the script.

You know the input:

Code: Select all

println input
You know what has been renamed:

Code: Select all

println getRenameLog()
So we can do this:

Code: Select all

(input - getRenameLog().keySet()).findAll{ it.isAudio() }.each{
	println it
}
And of course this:

Code: Select all

(input - getRenameLog().keySet()).findAll{ it.isAudio() }*.copyTo('/some/folder')

Re: Making amc copy unmatched files

Posted: 24 Mar 2014, 20:34
by gimmeth
Oh wow, I never would have though to do it like that.

I tried pasting that last line of code onto the end of the script and it didn't work.

Code: Select all

(input - getRenameLog().keySet()).findAll{ it.isAudio() }*.copyTo(format.music)
I tried it like this, and pointing to the path manually

Code: Select all

(input - getRenameLog().keySet()).findAll{ it.isAudio() }*.copyTo('F:/This is/where my file goes/')
Is there something I'm missing? I'm not sure how to debug this as the console window closes immediately and I'm not sure how to keep it open, and I generally have no idea what I'm doing. Thanks for all your help and the awesome program.

Re: Making amc copy unmatched files

Posted: 25 Mar 2014, 05:35
by rednoah
You'd just open cmd and then run the script? What have you been doing till now?? And just in case your editing with editor, then it's probably setting some BOM at the beginning of the file that'll make the script unusable.

And copyTo(format.music) what do you expect? That's just a template, not even a path.

This definitely works:

Code: Select all

(input - getRenameLog().keySet()).findAll{ it.isAudio() }*.copyTo('D:/this is/where my file goes/')
Just in case nothing gets renamed (in which the script aborts early) you can add this line before code:

Code: Select all

// skip notifications if nothing was renamed anyway
if (getRenameLog().isEmpty()) {
	return
}
I've tested this and it works 100% so any other issue are on your end for you to figure out. And always keep the cmdline open so you can see the errors! Otherwise you won't be able to. ;)

Re: Making amc copy unmatched files

Posted: 15 Aug 2014, 07:28
by rednoah
This new option should do the trick:
--def unsorted=y Process files that cannot be sorted out and move them to a separate folder

Re: Making amc copy unmatched files

Posted: 23 Aug 2014, 05:03
by scallawa
How do you define the folder that the unsorted files will be moved into?

Re: Making amc copy unmatched files

Posted: 23 Aug 2014, 10:52
by rednoah
That's hardcoded in the script and can't be changed via cmdline options at this point.

Files will be moved to:

Code: Select all

{output}/Unsorted/{fn}.{ext}