AppleScript to get all tracks from albums with less then a certain number of tracks How would I write an AppleScript to get all tracks from albums with less then n tracks  in iTunes?
Here is modified code from a related answer in 

Create playlists for full albums in iTunes (i.e. albums with all songs)

It is slow but does the job. It will print out the Album and the Track Names.

HTH

tell application "iTunes"
    -- The number of tracks
    set songsPerAlbum to 4

    set albumBuckets to {} as list
    set allSongs to (every track of library playlist 1 ¬
        whose enabled is true and podcast is false ¬
        and kind contains "Music") as list

    log "Debug: # of songs in library: " &amp; (get count of allSongs)

    -- Get list of albums, the slow way...
    repeat with currentTrack in allSongs
        set albumName to album of currentTrack as text
        if album of currentTrack is not missing value then
            if 0 is less than length of albumName then
                if albumBuckets does not contain album of currentTrack then
                    copy album of currentTrack to the end of albumBuckets
                end if
            end if
        end if
    end repeat

    -- Check each album
    repeat with currentAlbum in albumBuckets
        set albumSongs to (every track of library playlist 1 whose album is currentAlbum)

        -- Check track count
        if (count of albumSongs) is less than songsPerAlbum then
            log "Debug: Album: " &amp; currentAlbum
            repeat with trk in albumSongs
                log "Debug:      " &amp; (get name of trk)
            end repeat
        end if
    end repeat
end tell