dear macro-gurus:
i need some help getting data into an exceptionally quirky program (no menus, not alt-key combos, sometimes 65+ tabs to get form one part of screen to another, etc).
i need to read a list of folders, and give the program in a FileOpen dialog box a path that includes the name of the folder and the name of the first file in the folder.
the structure of the folders is consistent, and looks like this:
perfusion/subject1/subject1a/FirstFileName
perfusion/subject1/subject1b/FirstFileName
perfusion/subject2/subject2a/FirstFileName
perfusion/subject2/subject2b/FirstFileName
etc. so a sample path would be: perfusion\subject2\subject2a\FirstFileName
I have no idea where to start. I have used the following to read all files in one folder, but this has me really stumped. Any suggestions?
One idea: what if I manually made the list of files with path as a .txt file. Then how would I read each line in sequence as an input to this file open dialog box?
GetFileList>H:\Chart\test files\*.adicht,files
Separate>files,;,file_names
//Message>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
...........code.....
Label>end
Until>k,file_names_count
get folder list, and first file in each folder
Moderators: JRL, Dorian (MJT support)
Is this what you're trying to accomplish?
Maybe there is an easier way but this works well for me with perfect results every time.
I've tried to explain it as good as I can and I hope you can make any sense of off it all.
Maybe there is an easier way but this works well for me with perfect results every time.
I've tried to explain it as good as I can and I hope you can make any sense of off it all.
Code: Select all
//Get first file name and directory for 1st folder
GetFileList>C:\WINDOWS\*.*,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>k=k+1
Until>k,file_names_count
let>folder_1=file_names_%k%
StringReplace>file_names_%k%,C:\WINDOWS\,,file_name_1st_folder
let>display_file_name1_only=file_name_1st_folder
//Get first file name and directory for 2nd folder
GetFileList>C:\WINDOWS\system\*.*,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>k=k+1
Until>k,file_names_count
let>folder_2=file_names_%k%
StringReplace>file_names_%k%,C:\WINDOWS\system\,,file_name_2nd_folder
let>display_file_name2_only=file_name_2nd_folder
//Get first file name and directory for 3rd folder
GetFileList>C:\WINDOWS\Prefetch\*.*,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>k=k+1
Until>k,file_names_count
let>folder_3=file_names_%k%
StringReplace>file_names_%k%,C:\WINDOWS\Prefetch\,,file_name_3rd_folder
let>display_file_name3_only=file_name_3rd_folder
//Note how the numbers change for each GetFileList search starting with 1st, 2nd and 3rd
//Numbers you need to change when adding more folders
//let>folder_1=file_names_%k% [line 8]
//let>folder_2=file_names_%k% [line 18]
//let>folder_3=file_names_%k% [line 88]
//file_name_1st_folder [line 9 & 10]
//file_name_2nd_folder [line 19 & 20]
//display_file_name3_only [line 29 & 30]
//Let's display result of the 3 folders in your dialog
Dialog>dialog
Caption=
Width=445
Height=280
Top=119
Left=226
Label=First File in Folder 1: %display_file_name1_only%,8,8,true
Label=First File in Folder 2: %display_file_name2_only%,8,64,true
Label=First File in Folder 3: %display_file_name3_only%,8,120,true
Button=OK,40,176,75,25,1
Edit=msEdit1,8,24,425,folder_1
Edit=msEdit2,8,80,425,folder_2
Edit=msEdit3,8,136,425,folder_3
EndDialog>dialog
show>dialog,r