
    local CountSelItem = reaper.CountSelectedMediaItems( 0 )
    if CountSelItem == 0 then return end
    
    local retval, retvals_csv,desttr,par_ID,Undo

    if not NameTrack then NameTrack = 1 end
    
    if NameTrack == 1 then
          retval, retvals_csv = reaper.GetUserInputs( "Move selected items to a track", 1, "", "")
  reaper.Undo_BeginBlock()
Xtrack = reaper.CountTracks(0)    

    if (retval  == 0) or (tonumber(retvals_csv) > Xtrack)  then return end

retvals_csv = tonumber(retvals_csv) -1






    local CountTrack = reaper.CountTracks( 0 )

        local track = reaper.GetTrack(0,retvals_csv)


            par_ID =  reaper.CSurf_TrackToID( track, true )
            desttr = reaper.CSurf_TrackFromID( par_ID, true )
--            break


    
     
    if par_ID and desttr then 
        for i = 1,CountTrack do
            local track = reaper.GetTrack(0,i-1)
            local CountTrItem = reaper.CountTrackMediaItems( track )
            for i = CountTrItem-1,0,-1 do
                local item = reaper.GetTrackMediaItem( track, i )
                local sel = reaper.GetMediaItemInfo_Value( item, "B_UISEL" )
                if sel == 1 then
                    reaper.MoveMediaItemToTrack( item,desttr)
                    Undo = 1
                end    
            end   
end
end
end
  reaper.Undo_EndBlock("Move item to track", -1)
    
    reaper.UpdateArrange()


