Hi,
I did a simple test and write the following code, you can revise it accordingly to fit your own case:
int scannum = 1;
int filenumber =1;
pe_path path:=rootpath$; // Remeber rootpath
//Main for loop for creating folder structure
for(samplenum =1 ; samplenum < 5 ; samplenum++)
{
string temp$ = $(samplenum);
string Foldername$ = "Sample"+ temp$;
pe_mkdir folder:=Foldername$ cd:=1 path:=fpath$; // make new folder with name
//Nested for loop which is designed to import the files directly into newly created project folder.
for (filenumber =1; filenumber < 5; filenumber++)
{
//Convert Ints to string for use in file name creation
int scanstring = scannum;
string scannum$ = $(scanstring);
int filestring = filenumber;
string filenum$ = $(filestring);
string filename$;
scannum$=;
filenum$=;
// If-else loop differentiates between file name because after the 9th file the final four numbers become 0010 instead of 00010.
if (filenumber < 10)
filename$ = "Aps10_" + scannum$ + "_000" + filenum$;
else
filename$ = "Aps10_" + %(scannum$) + "_00" + %(filenum$);
filename$=;
//Creates filename string which will be used with import command to follow.
string fullfilename$ ="E:\\Subfolders\\"+filename$+".txt";
fullfilename$=;
//Imports file using fullfilename variable
impasc fname:= fullfilename$ options.impmode:=3; //start new book
//Iterates scannumber up one to move to the next scan.
};
pe_cd rootpath$; // Return to rootpath
};
Regards!
Sean
OriginLab Tech.