Thx I am using Javier’s idea that works good.

Here is a snippet of my rbase code.

LAUNCH mdgfile.bat||W

CREATE TEMP TABLE tmpfiles (tfilename TEXT 50)
LOAD tmpfiles FROM filename.dat


The contents of mdgfile.bat

DIR \\10.20.8.54\data\Rbase\In\*.csv /B > FileName.dat

That way I only read in the csv files.

Dan Goldberg


From: [email protected] <[email protected]> On Behalf Of Stephen 
Markson
Sent: Tuesday, October 15, 2019 8:12 AM
To: [email protected]
Subject: [RBASE-L] - RE: Grab file names in a folder

Hi Dan,

Here’s my code that does exactly what you want (I think). In our case we’re 
processing (parsing) a couple of thousand xml files:

I have a table FileListTemplate:

R>LIST FileListTemplate

   Table: FileListTemplate     No Lock(s)
   Descr: Control List of xml result files
   Last structure modification: 08 Nov 2017 14:06:19

No. Column Name        Attributes
--- ------------------ ------------------------------------------------------
   1 DLine              Type   : NOTE
   2 xmlFile            Type   : NOTE
   Current number of rows:         0

Then I use this code to get a table with the full filenames:
-- get the directory listing
OUTPUT TempDir.TXT
DIR \CBTScoring\Results\*.xml
OUTPUT SCREEN

-- load the filenames into table
DROP CURSOR xmlFile
DROP TABLE FileList
PROJECT TEMPORARY FileList FROM FileListTemplate USING *
GATEWAY IMPORT TXT TempDir.txt REPLACE FileList +
OPTION MESSAGES OFF|SHOW_PROGRESS OFF

-- delete irrelevant rows
DELETE FROM FileList WHERE DLine NOT LIKE '%.xml%'
DELETE FROM FileList WHERE DLine IS NULL

-- get file names
-- file names start at col 42 & are <100 chars
UPDATE FileList SET xmlFile=(SGET(DLine,99,42))

-- delete the directory info
ALTER TABLE FileList DROP COLUMN DLine

-- Please wait
PAUSE 3 USING 'Parsing files. Please wait...' CAPTION 'Load XML Results' +
&vPauseOpt


Then, I process the file:
-- set up variables
SET V vFileName TEXT,vAppointment TEXT

-- loop through the files
DROP CURSOR xmlFile
DECLARE xmlFile CURSOR FOR SELECT xmlFile FROM FileList
OPEN xmlFile
FETCH xmlFile INTO vFileName
WHILE SQLCODE<>100 THEN

  -- do your thing
  .
  .
  .
  FETCH xmlFile INTO vFileName
ENDWHILE



Regards,

Stephen Markson
The Pharmacy Examining Board of Canada
416.979.2431 x251

From: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>> On Behalf Of Dan 
Goldberg
Sent: October 10, 2019 12:48 PM
To: [email protected]<mailto:[email protected]>
Subject: [RBASE-L] - Grab file names in a folder

I need to write a routine that will grab a file, import it, process it, delete 
it, then grab then next file until they are done in that folder.

What command do I use to grab the file name if I do not know the name? They 
will be csv files.

TIA

Dan Goldberg
--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fwww.rbase.com%2fsupport%2fusersgroup_guidelines.php&c=E,1,asp5f3bUI9QFI3zwKrY0P8sOL50caGl_0uOgEUXi-l3RrTsMz8YYDnSU1NW4UTDvvyRiHnqBS0STRz7VW3UTrYLXtT0rVBt2TVLaPgzGE7NCQj4vKwbSU2wmKw,,&typo=1>
---
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/2E4830CEC16615458329D3D83342F8D0011EBAAD08%40EXCHANGE10<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2frbase-l%2f2E4830CEC16615458329D3D83342F8D0011EBAAD08%2540EXCHANGE10%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,lFbb5d3Q9_YY9tUk2Ok4128YLuSkqUYRijqYAVwbhlU6cTG3VtvgDm6rv-CK7zu2LjXJrqsZ0PCr1aAhD9A2P4Wy8uiFiPMiKOX9le4MKZBjPEtNNGFohn7odJg,&typo=1>.
--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/QB1PR01MB2978A2DC348F6025D01A100DD6930%40QB1PR01MB2978.CANPRD01.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/rbase-l/QB1PR01MB2978A2DC348F6025D01A100DD6930%40QB1PR01MB2978.CANPRD01.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>.

-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/2E4830CEC16615458329D3D83342F8D0011EBBEE35%40EXCHANGE10.

Reply via email to