I replicated the finding that you indicated, and I was not able to correct the issue using the approach that I was taking. So I went back to your original code, and simplified the approach and was successful in running a complete example.
Names Default To Here( 1 );
rc = Create Directory( "$TEMP/sub1" );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
Close( dt, save( "$TEMP/sub1/MFI big class.jmp" ) );
dt = Open( "$SAMPLE_DATA/body fat.jmp" );
Close( dt, save( "$TEMP/sub1/MFI body fat.jmp" ) );
dt = Open( "$SAMPLE_DATA/candy bars.jmp" );
Close( dt, save( "$TEMP/sub1/MFI candy bars.jmp" ) );
Show( Files In Directory( "$TEMP/sub1" ) );
dt_list = Multiple File Import(
<<Set Folder( "$TEMP\sub1\" ),
<<Set Stack Mode( "Table Per File" )
) << Import Data;
table_script = Expr(
//Move the column names listed in row 7 to the column headers
dt = Current Data Table();
dt << clear select;
dt << Clear Column Selection();
lastcol = N Col( dt );
header = 7;
For( i = 1, i <= lastcol, i++,
Column( i ) << set Name( (Column( i ) << get name) || Char( header ) )
);
);
For Each( {table}, dt_list,
Current Data Table( table );
table_script;
);
Jim