1. SHAMEEM KAKKAD
  2. PowerBuilder
  3. Saturday, 25 December 2021 07:29 AM UTC

Hi,

I need to get all pbls files from my computer (C,D,E,etc..). I did checked the dirlist, dirselect functions. but no use... 

 

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 26 December 2021 17:08 PM UTC
  2. PowerBuilder
  3. # Permalink

H Shameem,

I've attached a sample application to do what you want to do. It takes quite a while to run. (PB 2019 R3).

[EDIT] See my latest answer for the attachment.

It lists all pbl files of "all" Disk drives. I'm excluding all network mapped drives and some drives that I have for backups in the code though (E: and G:). You might want to change that. You can now select the drives you want to scan instead.

It's takes quite some time to finish! On my computer, running 2 complete SSD drives (450 GB and 250 GB) takes about 15 minutes. (the method that I suggested in another answer on this page, would work a lot faster, but has the inconvenience that you would have to run a batch file and write and read things from disk, cleanup etc.).

Instead of scanning full disks, it would be better to use a fixed list of some base directories (instead of the root folder. Imagine how much it takes to scan the windows related folders), but if you want to scan the whole disk from the root, including all subfolders, that's is what it's doing right now.

I've used n_filesys (by Roland Smith Topwizprogramming), but I've made some modifications since we are dealing with a recursive process and I didn't want the object to be auto-instantiate. It seems to behave a lot stabler when you create and destroy the object and do garbagecollect() and yield()).

Comment
  1. Miguel Leeuwe
  2. Tuesday, 28 December 2021 11:54 AM UTC
You would gain quite some execution time by excluding the %windir% folder. Maybe I'll add that to the sample one of these days. (I'm on a holiday anyway).
  1. Helpful
  1. SHAMEEM KAKKAD
  2. Friday, 31 December 2021 15:38 PM UTC
Hi Miguel,

Happy new year.



I can't see any button or any function for search in the example application which you send to search pbls from a computer...

  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 31 December 2021 15:41 PM UTC
Same to you!

Show me a screenshot, maybe that will clear things up.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 31 December 2021 18:28 PM UTC
  2. PowerBuilder
  3. # 1

Hi Shameem,

I accidentally posted the wrong sample application.

Here's the one for the search. (see attached). You have to look at the window "w_searchpbls_main".

[EDITED]

I've once again replaced the attachment: you can now select which disk(s) you want to scan and you can choose to exclude the windows and program files folders.

I've deleted the other attachment, so there's no more confusion.

Happy new year!

Attachments (1)
Comment
  1. SHAMEEM KAKKAD
  2. Wednesday, 5 January 2022 13:08 PM UTC
Wow..... Amazing..... it is working perfectly.....



Thank you verymuch....

Sorry for delayed reply....
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 5 January 2022 14:35 PM UTC
Yw Shameem, glad it works for you.

Maybe the speed can still be improved by searching only for:

1. first any subfolders (for the recursive process) and then

2. by "*.pbl" instead of "*.*"

That will take me some time though. For now it doesn't seem that bad.

regards

  1. Helpful
  1. SHAMEEM KAKKAD
  2. Friday, 7 January 2022 06:32 AM UTC
Thanks....
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 26 December 2021 12:29 PM UTC
  2. PowerBuilder
  3. # 2

 

A)
If you want to use a batch file and know which driveletters you have, you can create a batch (.bat or .cmd) file and use the "run()" command in powerbuilder to execute it. If you redirect the output to a text file, you can then later open the text file into powerbuilder using FileOpen() and FilereadEx() in linemode and process every line.

For example:

string ls_run
ls_run = "myPBL.cmd > pblFiles.txt" // not sure if you need to use one ">" or ">>"
run (ls_run, minimized!)

MyPBL.cmd:

rem use /b to only get the path and pbl names:
dir C:\*.pbl /s /b
dir D:\*.pbl /s /b

 

B)
But a much cleaner solution is to use n_filesys. The functions that you need are there, but they are not named "search" or anything like that.
To get all drives, use this one:

// -----------------------------------------------------------------------------
// SCRIPT: n_filesys.of_GetDrives
//
// PURPOSE: This function returns a list of disk drives with their type
// and volume label.
//
// ARGUMENTS: as_drive - Drive letter array (By Ref)
// aul_type - Drive type array (By Ref)
// as_label - Volume label array (By Ref)

And to get all the files on a specific drive, use this one:

// -----------------------------------------------------------------------------
// SCRIPT: n_filesys.of_GetFiles
//
// PURPOSE: This function is a simplified version that only returns
// filename and subdirectory flag.
//
// ARGUMENTS: as_filespec - File path
// as_name - File Name array (By Ref)
// ab_subdir - Subdirectory flag (By Ref)

 

Comment
  1. Chris Pollach @Appeon
  2. Sunday, 26 December 2021 17:57 PM UTC
Hi Miguel ... IMHO "A" is the way to go. I've used that approach in the past very successfully.
  1. Helpful
  1. Miguel Leeuwe
  2. Sunday, 26 December 2021 18:02 PM UTC
I agree, at least when you want to do a full disk scan. Roland's object works nicely if you know which folder(s) you want to work with though (or if you're very patient) :)

  1. Helpful
There are no comments made yet.
SHAMEEM KAKKAD Accepted Answer Pending Moderation
  1. Sunday, 26 December 2021 12:03 PM UTC
  2. PowerBuilder
  3. # 3
  • What do you mean with "get pbl files"? List? Copy?

        >>  I need to search all PBLs from a computer (C,D,E......) . neet to list (Like Windows search..)

  • From where do you want to do this? Powerbuilder code, batch file, cmd file? 

        >> Powerbuilder code...

        >> or applicable from batch file but which need to execute from powerbuilder

  • Explain a bit more what "but no use" means. Were Dirlist Dirselect of "no use", why not?

       >> I did check with DirList and DirSelect.. In this case I need to select all folders. It is very complicated functionality.

 

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 26 December 2021 08:48 AM UTC
  2. PowerBuilder
  3. # 4

Hi Shameem,

Please try to be more specific if you want some help:

  • What do you mean with "get pbl files"? List? Copy?
  • From where do you want to do this? Powerbuilder code, batch file, cmd file? 
  • Explain a bit more what "but no use" means. Were Dirlist Dirselect of "no use", why not?

regards

Comment
  1. Miguel Leeuwe
  2. Sunday, 26 December 2021 08:54 AM UTC
Check out Roland's FileSys object. It has many functionalities:

https://topwizprogramming.com/freecode_filesys.html
  1. Helpful 1
  1. SHAMEEM KAKKAD
  2. Sunday, 26 December 2021 12:05 PM UTC
I already downloaded. But there is no search option.
  1. Helpful
  1. Miguel Leeuwe
  2. Sunday, 26 December 2021 12:10 PM UTC
I'll have a look, I might have used it myself in the past.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.