How do I sort a playlist by filename in iTunes?

Solution 1:

Unfortunately this is not possible. As there isn't a column available for filename, one can't sort by it.

If you're willing to take the time, you can input the metadata and sort by track number. You'd only really need to enter the track numbers incrementally (like the file names), but you might instead choose to number the tracks per disk and then input which disk they're on as well. This way would need to be sorted by Album rather than track number, as it would otherwise go 1,1,1,2,2,2,3,3,3,… rather than 1,2,3,…1,2,3,…1,2,3,….

Sorry it's so inconvenient, but I hope this works for you. :)

Solution 2:

If you drag a folder on a playlist from Finder and sort the playlist by the first column, the items are usually sorted by filename.

You might also run a script like this in AppleScript Editor:

tell application "iTunes" to repeat with t in (get selection)
    set comment of t to POSIX path of (get location of t)
end repeat

Then sort the tracks by the comment field.

To delete all tags, run sudo easy_install pip;sudo pip install mutagen, then run something like for f in *.mp3;do mid3v2 --delete-all "$f";done, and then tell iTunes to update the tags by selecting the items and running tell app "iTunes" to refresh selection.