cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Pro extension simulates Bayesian Optimization runs. Prediction formulas stand in for experimental results. Run simulations and compare results. Download and use the extension.

Uncharted

Choose Language Hide Translation Bar
Craige_Hales
Super User
Files In Directory

This example uses Files In Directory to get a list of all the files in a directory.  It then looks for all the .jmp files, opens (and later closes) them one by one, making a summary table along the way.  The $sample_data directory has sub-directories which will be in the list but are skipped by the EndsWith test.  EndsWith is case sensitive; you might want EndsWith(LowerCase(filename), ".jmp") to get the files that end in .JMP and .jmp.

Files In Directory does not need the trailing /, but doesn't mind it either.  But the trailing / is important when the file names in the list are concatenated to the directory.  JMP takes care of the windows vs mac / and \ issues.

directory = "$sample_data/";

fileNames = Files In Directory( directory );

summary = New Table( "summary", New Column( "name", character ), New Column( "rows", numeric ) );

For( iFile = 1, iFile <= N Items( fileNames ), iFile++,

  filename = fileNames[iFile];

  If( Ends With( filename, ".jmp" ),

    dt = Open( directory || filename );

    summary << addrows( 1 );

    summary:name = filename;

    summary:rows = N Rows( dt );

    Close( dt, "nosave" );

  );

);

10722_FilesInDirectory.PNG

There is a recursive option if you want those files too...


10723_FilesInDirRecursive.PNG

Last Modified: Oct 18, 2016 9:31 PM