- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Open Files in Directory based on a List of Variable Filenames
Hi all,
I have a list of filename. This list of filename is variable and change from to time. I want to match these file name to the files available in a directory. If match , open the files.
I write below code and run it. It does not work.
Need guidance here.
folder = "C:\savefile\";
filename ={"Jan", "Feb", "Mar"};
filelist= Files In Directory(folder);
For(i=1, i<= N items(filename), i++,
If (Contains(filename[i], "filelist"),
Open (folder || filename[i] ||".jmp"))
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Open Files in Directory based on a List of Variable Filenames
I had to do couple of modifications.
1. Contains should have list as first argument and the filelist should not be in quotes
2. You have to concatenate .jmp to filelist
This slightly modified modified example should give you an idea what to modify:
folder = "C:\Program Files\SAS\JMPEA\17\Samples\Data\";
filename = {"AdverseR", "Air Traffic", "Abrasion"};
filelist = Files In Directory(folder);
For(i = 1, i <= N Items(filename), i++,
If(Contains(filelist, filename[i] ||".jmp"),
Open(folder || filename[i] || ".jmp")
);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Open Files in Directory based on a List of Variable Filenames
Are the actual file names you are looking for, named "Jan" or "Feb" or "Mar"? or, are you looking for those month abbreviations to be part of the file name?
A sample of what the actual filenames are would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Open Files in Directory based on a List of Variable Filenames
Jim, the file name is "Jan" or "Feb" or "Mar"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Open Files in Directory based on a List of Variable Filenames
I had to do couple of modifications.
1. Contains should have list as first argument and the filelist should not be in quotes
2. You have to concatenate .jmp to filelist
This slightly modified modified example should give you an idea what to modify:
folder = "C:\Program Files\SAS\JMPEA\17\Samples\Data\";
filename = {"AdverseR", "Air Traffic", "Abrasion"};
filelist = Files In Directory(folder);
For(i = 1, i <= N Items(filename), i++,
If(Contains(filelist, filename[i] ||".jmp"),
Open(folder || filename[i] || ".jmp")
);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Open Files in Directory based on a List of Variable Filenames
Thank you, Jarmo. It works.