Since the beginning of times, music was ment to be shared.
But, if you acquired music from iTunes Store, either as a direct buy or through the amazing iTunes Match service, be aware that your M4A files contain personal information.
Use exiftool
to inspect an M4A file:
$ exiftool -UserID -TransactionID -ItemID -AppleStoreCatalogID -AppleStoreAccount -UserName some-itunes-acquired-music-file.m4a
User ID : 0x12345678
Transaction ID : 0xabcdef98
Item ID : 0x34e6b89a
Apple Store Catalog ID : 9876543210
Apple Store Account : [email protected]
User Name : Avi Alkalay
This is unacceptable.
There is no official music tagger that totally cleans this information. So currently there are 3 ways to clean this mess:
- Transcode files to another music format or even to AAC/M4A. This is lossy and unacceptable.
- Use
ffmpeg
incopy
mode to rewrite the files without transcoding (lossless), but loosing header info. You'll have to retag your files. - Do the right thing and cirurgicaly delete only the offending bytes on the file's header
The method implemented by the un-istore.sh
script is #3.
Simply run it in the root folder of you music. It will recursively seek for all offending M4A files and clean them up. Provide 2 parameters to the script:
- Your user name as it appears in the music files. Something like "Your Name".
- Your Apple user ID, which is an e-mail address as "[email protected]".
Like this:
$ cd MyMusic
$ un-istore.sh "Avi Alkalay" "[email protected]" | tee -a /tmp/un-istore.log
Try it first on an external copy of your music files, before using it directly on your beloved music collection.
The script works on Linux and might work on macOS too (use your Mac terminal to run it).
Use exiftool
to inspect an M4A file:
$ exiftool -UserID -TransactionID -ItemID -AppleStoreAccount -AppleStoreCatalogID -UserName some-itunes-acquired-music-file.m4a
User ID : 0xffffffff
Transaction ID : 0xffffffff
Item ID : 0x34e6b89a
Apple Store Catalog ID : 9876543210
Apple Store Account : iTunes Store
User Name : iTunes Store
Compare it with the dirty example above. Catalog ID and Item ID are kept because they are not private information and they help with metadata when sharing music through iMessage.
You can also use the check-istore.sh
script to recursively check all your files. It
will point you the files that are still dirty. But there will be none. I wrote
the check-istore.sh
script while developing un-istore.sh
to check its
effectiveness. It is unneeded anymore but I keep it here for the records.
The un-istore.sh
shell script contains a powerful perl script that cirurgically
changes only the 20 or 30 offending bytes on your files. No more, no less. See for
yourself the simplicity an powerfulness
of its regular expressions.
The un-istore.sh
script is faster and superior than the ffmpeg
in copy
mode method documented in this section. But if you are just curious about it, here it is. Use terminal or command line, change directory to the folder containing your iTunes files and paste this:
cd folder/with/M4A/files
mkdir clean;
\ls *m4a | while read f; do
ffmpeg -i "$f" -acodec copy -vn "clean/$f" < /dev/null;
done
After running this, a cleaned up version of your files will be under clean
folder.
ffmpeg
will completely rewrite your files (forgetting obscure tags as the ones
we want to delete) while -acodec copy
guarantees a plain copy (and not transcoding)
in the audio level. You will loose some of your tags and cover art too, though. So retag
your new files after that.
Use un-istore.sh
provided in this repository for a faster and more precise fix.