| View previous topic :: View next topic |
| Author |
Message |
Rory Power User


Joined: 04 Nov 2004 Posts: 51 Location: Brasilia DF, Brasil
|
Posted: Thu Nov 04, 2004 6:14 am Post subject: Dir$ turbo? |
|
|
HI all,
Im Using the "Dir$" Function to return file names for reading and relocation, the trouble is Im working with 14000 files per folder, and each time "Dir$" is processed in a loop it is taking about 5 seconds, for the 14000 files thats 16 hours, ^Almost^ the same code in Excel/VBA took only 15 minutes per folder, just wondering if there exists a faster way to do this in OOo?
Many thanks in advance _________________ Rory
/Cries
OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2) |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Thu Nov 04, 2004 10:01 am Post subject: |
|
|
Why would you wanna do this with a scripting language like Starbasic? This is a task suitable for languages like C++.
However maybe it is faster if you use the ucb layer (getFolderContents()).
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Rory Power User


Joined: 04 Nov 2004 Posts: 51 Location: Brasilia DF, Brasil
|
Posted: Thu Nov 04, 2004 10:17 am Post subject: |
|
|
Well Im not sure, Im opening each file reading the first line, and depending on this, reading a random number of lines and writing these out to another file.
Im not sure of other easier ways to do this, i am only doing it this way as, my knowledge of macros and scripting grew as my work requirements grew.
I would be interested to know of other ways at looking at this, in regard to new chalenges and things to learn
Thanks again
Rory _________________ Rory
/Cries
OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2) |
|
| Back to top |
|
 |
Rory Power User


Joined: 04 Nov 2004 Posts: 51 Location: Brasilia DF, Brasil
|
Posted: Thu Nov 04, 2004 11:29 am Post subject: |
|
|
Hi again, I think ive figured this out, and you would have no doubht spotted it had I posted the code,
INside the loop i had ****Dir$"folder Path"*** when I changed this for just Dir$ things have speeded up a lot, it is still very slow on the first Dir before the loop but inside the loop its much better yet still slower than excel / VBA, is this to be expected??? Now im curious as to any other options/ ways? I have to do the same thing.
If it would help I could post my macro altho its a bit of a monster, and 99% of the 'notes are in portuguese _________________ Rory
/Cries
OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2) |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Thu Nov 04, 2004 3:40 pm Post subject: |
|
|
Great that it works!!
And just as a note: Such things are usually done with shell scripts (on Linux), and that's also just scripting language not too hard to learn. _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Rory Power User


Joined: 04 Nov 2004 Posts: 51 Location: Brasilia DF, Brasil
|
Posted: Mon Nov 08, 2004 4:17 am Post subject: |
|
|
Erk more problems,
on the first time I use dir, prior to the loop i use as follows,
Dir$"filepath"\r_*.dat
now to speed things up a great deal, inside of the loop i only put Dir"this speeded things up by 12 hours only problem is it grabs everything in the file not only the dat files so now is poping up errors everytime it opens the wrong file
any ideas how to fix this without punishing the time
Thanks in advance "again" _________________ Rory
/Cries
OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2) |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Mon Nov 08, 2004 7:45 am Post subject: |
|
|
You mean you want to use wildcards? Like "only take every .dat file no other formats"?
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Rory Power User


Joined: 04 Nov 2004 Posts: 51 Location: Brasilia DF, Brasil
|
Posted: Mon Nov 08, 2004 9:01 am Post subject: |
|
|
yes,
| Code: | dim sDirPath as string
Dim nextfile as string
sDirPath = "E:\REPORTS\GERAL\OOo\Dat"
Nextfile = Dir$(SdirPath & "r*.dat)
do untill nextfile = ""
open Nextfile for input as #1
' do my stuff
close #1
nextfile = Dir$
loop |
now when I do the dir inside the loop it opens every file in the folder
IF inside the loop I put the whole path Nextfile = Dir$(SdirPath & "r*.dat)
then everytime it reaches that line in the loop it stops for 20 seconds
thanks again
Soreheaded _________________ Rory
/Cries
OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2) |
|
| Back to top |
|
 |
|