Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Need some help with loading multiple files form a remote system.
There is a base folder and it has many sub folders.
I need to conditionally load all the files from the lowest level
Ex. C:\CAMP_BASE
C:\CAMP_BASE\OCT-10
C:\CAMP_BASE\NOV-10
C:CAMP_BASE\ARCH <------------------------ Skip folder
C:CAMP_BASE\ARCH\\NOV-10\FILE_FOLD1 <- Skip
C:CAMP_BASE\SOMEOTHER <-------------------Skip folder
C:\CAMP_BASE\OCT-10\FILE_FOLD1
C:\CAMP_BASE\OCT-10\FILE_FOLD2
C:\CAMP_BASE\NOV-10\FILE_FOLD1
C:\CAMP_BASE\OCT-10\FILE_FOLD1_REDO_T <-------------------Skip folder
C:\CAMP_BASE\OCT-10\FILE_FOLD1_REDO_T\OCT-10\FILE_FOLD1 <--- Skip
Condition 1 : skip all the folders that do NOT have "-" in the name
Condition 2 : In the next level skip any folder with a name contains word "REDO"
So that I will end up with the following folders
C:\CAMP_BASE\OCT-10\FILE_FOLD1 | |
| C:\CAMP_BASE\OCT-10\FILE_FOLD2 |
C:\CAMP_BASE\NOV-10\FILE_FOLD1 |
Any Idea?
Thanks,
Aji Paul.
Replace
if (substringcount('$(SubDirectory)','-')) then
with
if (substringcount('$(SubDirectory)','-') and substringcount('$(SubDirectory)','REDO')=0 ) then
Additional info
These folders may contain many text files and need to load all of them *.txt
C:\CAMP_BASE\OCT-10\FILE_FOLD1 |
C:\CAMP_BASE\OCT-10\FILE_FOLD2 |
C:\CAMP_BASE\NOV-10\FILE_FOLD1 |
Maybe something like the script below (adapted from Henric's code here😞
Set vConcatenate = ;
sub ScanFolder(Root)
for each FileExtension in 'txt'
for each FoundFile in filelist( Root & '\*.' & FileExtension)
FileList:
$(vConcatenate)
LOAD *, '$(FoundFile)' as SourceFile
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 2 lines);
Set vConcatenate = Concatenate;
next FoundFile
next FileExtension
for each SubDirectory in dirlist( Root & '\*' )
if (substringcount('$(SubDirectory)','-')) then
call ScanFolder(SubDirectory)
end if
next SubDirectory
end sub
Call ScanFolder(' C:\CAMP_BASE') ;
Hi,
How do I exclude name that contain REDO?
Thanks,
Aji Paul
Replace
if (substringcount('$(SubDirectory)','-')) then
with
if (substringcount('$(SubDirectory)','-') and substringcount('$(SubDirectory)','REDO')=0 ) then
Thanks for the update! Will update you soon
Hi Thank you very much!
It worked awesome!