For the latest version of JMP Help, visit JMP.com/help.


Publication date: 04/21/2023

Get a List of Filenames

To obtain a list of filenames in a specific directory, use the Files In Directory function.

Files In Directory( path, <recursive( 0 | 1 )> );

Both filenames and subdirectory names are returned as shown in the following example:

Files In Directory( "$SAMPLE_DATA" );

{ "2D Gaussian Process Example.jmp", "Abrasion.jmp", ... "Design Experiment", "Detergent.jmp", ... }

Notice that the files within the Design Experiment subdirectory are not included. And only files in the root $SAMPLE_DATA directory are listed.

To return a list of all file names, add the optional recursive(Boolean) argument to Files In Directory:

Files In Directory( "$SAMPLE_DATA", recursive( 1 ) );

{ "2D Gaussian Process Example.jmp", "Abrasion.jmp", ... "Design Experiment/2x3x4 Factorial.jmp", "Design Experiment/Algorithm Data.jmp", ... }

To get the full pathnames, recurse the directories and concatenate the file paths and file names. The following example loops through each file in the $SAMPLE_DATA directory and subdirectories. The file path is concatenated to each file name.

names = Files In Directory( "$SAMPLE_DATA", recursive( 1 ) );
For( i = 1, i <= N Items( names ), i++,
	names[i] = Convert File Path( "$SAMPLE_DATA" ) || names[i]
);
names;

{"/C:/Program Files/SAS/JMP/17/Samples/Data/2D Gaussian Process Example.jmp",

"/C:/Program Files/SAS/JMP/17/Samples/Data/Abrasion.jmp", ... }

The Files in Directory command accepts native and POSIX paths, as well as paths using path variables. See Path Variables for more information about working with paths.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).