Making amc copy unmatched files

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
gimmeth
Posts: 7
Joined: 24 Mar 2014, 06:59

Making amc copy unmatched files

Post 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()));
		}
	}

User avatar
rednoah
The Source
Posts: 23946
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Making amc copy unmatched files

Post 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')
:idea: Please read the FAQ and How to Request Help.
gimmeth
Posts: 7
Joined: 24 Mar 2014, 06:59

Re: Making amc copy unmatched files

Post 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.
User avatar
rednoah
The Source
Posts: 23946
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Making amc copy unmatched files

Post 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. ;)
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23946
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Making amc copy unmatched files

Post 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
:idea: Please read the FAQ and How to Request Help.
scallawa
Posts: 3
Joined: 22 Aug 2014, 23:30

Re: Making amc copy unmatched files

Post by scallawa »

How do you define the folder that the unsorted files will be moved into?
User avatar
rednoah
The Source
Posts: 23946
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Making amc copy unmatched files

Post 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}
:idea: Please read the FAQ and How to Request Help.
Post Reply