$loop problem with multiple playlist generation

Hi
I have the following code as part of an action to generate multiple playlists:

$filename(\\NAS\Music\ArtistPlaylists\,$regexp(%_folderpath%,'^\\\\.+?\\.+?\\.+?\\(.+?)\\.*',$1))) - Rated Tracks.m3u8,utf-8)$loop(%track%)$loop(%album%)$loop(%albumartistsort%)#EXTINF:%_length_seconds%,%artist% - %title%
$replace(%_path%,'\\NAS\Music\','M:\')
$loopend()$loopend()$loopend()

I have also tried reversing the order of the nested loops i.e
$loop(%albumartistsort%)$loop(%album%)$loop(%track%)

When I run the action I have a list of tracks in the main MP3tag window that includes the following tracks. I would like the playlist to be generated in this order. Note the 4th track on the screenshot below which is in a different path/location. I have applied a sort using a new column in the main MP3tag windows to get this order using the following in the sort by field under customise columns:
%albumartistsort% %album% %track%

image

I have also tried the following using the %dummy% variable instead of the nested loops, which I understood would loop through the files as per what appears on screen

$filename(\\NAS\Music\ArtistPlaylists\,$regexp(%_folderpath%,'^\\\\.+?\\.+?\\.+?\\(.+?)\\.*',$1))) - Rated Tracks.m3u8,utf-8)$loop(%dummy%)#EXTINF:%_length_seconds%,%artist% - %title%
$replace(%_path%,'\\NAS\Music\','M:\')
$loopend()

None of these options are working as the 4th track always appears at the end of the generated playlist. Any idea what to do to get the playlist generated in the desired order please (ie irrespective of file location)
Thanks
G

If you want to get the order as shown in the file list, use a (single) loop like this:
$loop(1,1)

The other problems arising from the path or so are not dealt with here.