This should work (edided excerpt from your script)
name = Left( y[1], Length( y[1] ) - 4 );
Open(
"C:jmp\" || y[i],
columns( Acct num = Character, . = Omit ),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Labels( 0 ),
Column Names Start( 1 ),
Data Starts( 1 ),
Lines To Read( All ),
Year Rule( "10-90" )
)
) << New Column( "source", character, set each value( name ) );
Only change is the placement of and the code inside New Column().
But you can also use the "Create source column" option of Concatenate() instead of adding a new column to each table.
Try the script below. an alternative approach to this problem that also lets the built-in functionalty of Concatenate() handle the source column.
mypath = "C:\jmp";
y = Files In Directory( mypath );
//remove all non-text files from y
For( i = N Items( y ), i > 0, i--,
If( Ends With( y[i], "txt" ),
,
Remove From( y, i )
)
);
n = N Items( y );
//Make list y1 of open() expressions
y1 = {};
For( i = 1, i <= n, i++,
y1[i] = Parse(
Eval Insert(
"Open(mypath||\!"^y^\!",columns(Acct num = Character, . = Omit ),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Labels( 0 ),
Column Names Start( 1 ),
Data Starts( 1 ),
Lines To Read( All )
))"
)
)
);
// (Open and) Concatenate files
Eval( y1[1] ) << Concatenate(
Eval List( y1[2 :: n] ),
Create source column
);
//Close sub-files
For( i = 1, i <= n, i++,
Close( Data Table( y[i] ), nosave )
);