You too may have a vast collection FLAC files and an iphone - which
doesn't speak FLAC.

I've written an Applescript App that will take a folder of FLAC files
and convert them to Apple Lossless (ALAC) and incorporate the cover.jpg
or folder.jpg into the metadata of the created files. It also does AAC
at 160Kb/s and 320Kb/s.

Download here: http://118design.co.uk/software/iFLAC.zip

Since I have not purchased an Apple developer licence, this is unsigned
software. If you wish to trust me and try it, you will have to do this:
https://support.apple.com/kb/PH21769?locale=en_US

You can drop folders of FLACs onto the app or just open it and select a
folder. The result appears in a folder called Audio on your Desktop.

The hard work is done by 'ffmpeg' (https://ffmpeg.org/) and
'AtomicParsley' (http://atomicparsley.sourceforge.net/).

For the technically minded, this is the Applescript:


Code:
--------------------
    
  
  on open iFLAC
        set FLACpath to POSIX path of iFLAC
        
        
        if FLACpath ends with "/" then
                ShellSub(FLACpath)
        else
                
                display alert "Folders only please!"
                
        end if
        
  end open
  
  set FLACpath to POSIX path of (choose folder with prompt "Please choose a 
folder containing FLAC files") as text
  
  
  ShellSub(FLACpath)
  
  error number -128
  
  
  on ShellSub(FLACpath)
        
        try
                set quality to do shell script "defaults read com.ajw.aac 
quality"
        on error
                set quality to "160Kb/s"
        end try
        
        set quality to the button returned of (display dialog "Set audio 
quality:" buttons {"160Kb/s", "320Kb/s", "ALAC"} default button quality)
        
        set TStart to current date
        
        do shell script "defaults write com.ajw.aac quality " & quality
        
        set FLACpath to EscapeSub(FLACpath)
        
        set scriptpath to POSIX path of (path to me as text) & 
"/Contents/Resources/"
        set scriptpath to EscapeSub(scriptpath)
        
        do shell script scriptpath & "AAC.sh" & space & FLACpath & space & 
quoted form of text 1 thru 4 of quality
        
        set TStop to current date
        
        display alert "Processing complete in " & (TStop - TStart) & " 
seconds!" message "Your files are on the desktop."
        
  end ShellSub
  
  on EscapeSub(path)
        set myTemp to ""
        
        repeat with c in every character in path
                set myTemp to myTemp & "\\" & c
        end repeat
        
        return myTemp
  end EscapeSub
  
  
--------------------


This is a shell script it calls:



Code:
--------------------
    
  #!/bin/sh
  
  
  cd "$1"
  
  
  MyPath="$HOME/Desktop/Audio/"$(basename "$(dirname "$1")")"/${PWD##*/}"
  
  
  mkdir -p "$MyPath"
  
  
  if [ "$2" = "ALAC" ]; then
        ls *flac | while read f; do "$(dirname "$0")/ffmpeg" -i "$f" -acodec 
alac  "$MyPath/$(basename "${f/.flac}").m4a" > /dev/null & done
  else
        ls *flac | while read f;do "$(dirname "$0")/ffmpeg" -i "$f" -c:a aac 
-b:a $2 "$MyPath/$(basename "${f/.flac}").m4a" > /dev/null & done
  fi;
  
  
  
  # wait for spawned ffmpeg processes to finish
  while ps axg | grep -vw grep | grep -w ffmpeg > /dev/null; do sleep 1; done
  
  
  
  # copy cover art to local folder
  cd "$MyPath"
  cp "$1"/cover.jpg cover.jpg
  cp "$1"/folder.jpg cover.jpg
  
  # make files with cover art
  for f in *.m4a; do "$(dirname "$0")/AtomicParsley" "$f" --artwork cover.jpg; 
done; 
  # remove files without cover art
  find . -type f -not -name '*temp*' -print0 | xargs -0 rm --
  # rename files with cover art
  for f in *.m4a; do g=${f//-temp*./.}; mv "$f" "$g"; done;
  
  
  exit 0
  
  
--------------------



Please use it, copy it, change it, improve it, tell me what you did but
don't sell it because you would be in breach of the licences of the
incorporated software.

Cheers

Tony Wilson


------------------------------------------------------------------------
Wiredcharlie's Profile: http://forums.slimdevices.com/member.php?userid=35115
View this thread: http://forums.slimdevices.com/showthread.php?t=106937

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to