Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
Hi. I am trying to run this statement for all the .txt files available in the directory. I tried using a For loop but it only picked up the 1st .txt file available in the directory. Appreciate help from you guys out there...
for each Ext in 'txt'
for each FileName in ('$(sPathResources)'&'\*.' &Ext)
File:
LOAD *FROM [$(FileName)]
(txt, codepage is 1252, embedded labels, delimiter is spaces);
STORE File INTO $(FileName).qvd (qvd);DROP Table File;
NEXT FileName
NEXT Ext
p/s: sPathResources = path where files are stored.
 jeffmartins
		
			jeffmartins
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi erin wan,
Try to use this code
for each File in FileList('$(sPathResources)\*.txt')
File:
LOAD *, FileBaseName() as FileName
FROM [$(File)]
          (txt, codepage is 1252, embedded labels, delimiter is spaces);
let vFileName = FieldValue('FileName', 1);
drop field FileName;
STORE File INTO $(sPathResources)\$(vFileName).qvd (qvd);
DROP Table File;
NEXT File
Regards
 jeffmartins
		
			jeffmartins
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi erin wan,
Try to use this code
for each File in FileList('$(sPathResources)\*.txt')
File:
LOAD *, FileBaseName() as FileName
FROM [$(File)]
          (txt, codepage is 1252, embedded labels, delimiter is spaces);
let vFileName = FieldValue('FileName', 1);
drop field FileName;
STORE File INTO $(sPathResources)\$(vFileName).qvd (qvd);
DROP Table File;
NEXT File
Regards
 
					
				
		
 rwunderlich
		
			rwunderlich
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		You are missing the FileList keyword.
for each FileName in FileList('$(sPathResources)'&'\*.' & Ext)
-Rob
 
					
				
		
Thanks jeffmartins! It works 
 
					
				
		
Thanks Rob 
