karaoke archiver

Just talk about kJams stuff with each other, describe things you did that worked, talk about your setup, anything that doesn't fit into the other forums!
DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: karaoke archiver

Post by DeusExMachina »

Dave, you might, but here is the issue:
since it works directly on folders of tracks, it makes sense to use it in the Finder, but not really from within kJams. I mean, how would you even select the folder to process? Also, if you DID use it from within kJams, kJams would immediately lose track of all the tracks, because now they are zipped out from under it!
It was really written as a pre-import processor.
Last edited by DeusExMachina on Thu Apr 23, 2015 12:07 pm, edited 1 time in total.

LasVegas
Posts: 14
Joined: Sun Oct 12, 2014 12:51 pm

Re: karaoke archiver

Post by LasVegas »

You're right. I am running it as a Service rather than a Folder Action. It is receiving the list of files in the folder and the results consist of the full path of the zip file (echo "$FILEPATH"), the file to be compressed (echo "$f") and the results of the zip action indicating compression %. This is repeated for each file and ignored by the final Growl notification. Perhaps adding a 'return (null)' of some sort at the end might stop the error? Like I said. The files compress fine before the error.

Your original script works fine except that parsing the extension in that fashion fails to recognize files with periods within the name of the file (IE: middle initial). The changes I made, uses only the text after the final period resulting in the correct extension and all text before the final period for the correct path.

Las Vegas

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: karaoke archiver

Post by DeusExMachina »

Oh, I misunderstood. Thought it was failing at the script, not after. I'll do some research.
Could you post some exemplar output? The issue is clearly in how Automator perceived the output vs. running independently so that is where the clues will be.
A(lso, since kJams is going to replace the period in the file name anyway, another solution would have been to preprocess the file names to remove them, but that is not an issue now.)
But as a work around, you could always enclose the shell script in a try block.

try
shell script code
on error
error code
end try

LasVegas
Posts: 14
Joined: Sun Oct 12, 2014 12:51 pm

Re: karaoke archiver

Post by LasVegas »

DeusExMachina wrote:But as a work around, you could always enclose the shell script in a try block.
Yep! That solved it. Just ignore the error. I just replaced the last line of the 'if' loop with:

Code: Select all

fi >/dev/null
Works great!

Las Vegas

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: karaoke archiver

Post by DeusExMachina »

feel free to post your changes in /Code.

LasVegas
Posts: 14
Joined: Sun Oct 12, 2014 12:51 pm

Re: karaoke archiver

Post by LasVegas »

DeusExMachina wrote:feel free to post your changes in /Code.
Sorry. I have no idea how to do that... :(

LasVegas

dave
Site Admin
Posts: 6684
Joined: Sun Sep 18, 2005 8:02 am
Location: Seattle
Contact:

Re: karaoke archiver

Post by dave »

just post it here

LasVegas
Posts: 14
Joined: Sun Oct 12, 2014 12:51 pm

Re: karaoke archiver

Post by LasVegas »

The full code to replace the script in Automator is:

Code: Select all

for f in "$@"
do
	FILETYPE="${f##*.}"	
MP=mp3
CDG=cdg
	if ( [ "$FILETYPE" = "$MP" ] || [ "$FILETYPE" = "$CDG" ] );
	then
		FILEPATH="${f%.*}.zip"
		echo "$FILEPATH"
		echo "$f"
		zip -j -m "$FILEPATH" "$f";
	fi >/dev/null
done
LasVegas

dave
Site Admin
Posts: 6684
Joined: Sun Sep 18, 2005 8:02 am
Location: Seattle
Contact:

Re: karaoke archiver

Post by dave »

8)

Post Reply