Category Archives: macOS

Quick action: convert to m4a

If you do not want to keep large WAV or AIFF files on your disk that eat up precious space, you can use Apple’s Automator to write a quick action to easily convert these files to m4a.

Open Apple’s Automator and create a new quick action.

Automator: convert audio files to m4a
for f in "$@"
do
  afconvert -f m4af -d aac "$f" "${f%.*}.m4a"
done

You can also have Automator delete the original file after conversion:

Automator: convert audio to m4a and delete original file
for f in "$@"
do
  # Convert WAV to M4A
  afconvert -f m4af -d aac "$f" "${f%.*}.m4a"
  
  # Check if conversion succeeded before deleting
  if [ $? -eq 0 ]; then
    rm "$f"
  else
    echo "Conversion failed for $f, original not deleted."
  fi
done

These quick actions also work on video files (like mp4), in case you are only interested in keeping the audio track of a video file.

The above quick action workflows can be downloaded below:

To install the workflows as quick actions, you can download the above files, unzip and execute. macOs will then install the workflows. Your macOS security protection still keeps them disabled. You have to enable them in system preferences. Open Login Items & Extensions, under Extensions, behind the Finder line, hit the “i” button:

macOS system settings: enable the quick action

Source: These scripts have been developed with the help of a generative large language model.