Author Topic: Development of a program for automatic search for music and movies  (Read 21600 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Development of a program for automatic search for music and movies
« Reply #60 on: June 27, 2020, 12:47:31 am »
List retrieved and sorted in about 1 second, on my PC.

Code: QB64: [Select]
  1. DEFLNG A-Z
  2.     FUNCTION load_dir& (s AS STRING)
  3.     FUNCTION has_next_entry& ()
  4.     SUB close_dir ()
  5.     SUB get_next_entry (s AS STRING, flags AS LONG, file_size AS LONG)
  6.  
  7.  
  8. SCREEN _NEWIMAGE(1280, 740, 32)
  9. _DELAY .25
  10. DIM cd$, i, w$
  11.  
  12. PRINT "Creating tree."
  13. t# = TIMER(0.001)
  14. MakeTree _CWD$ 'testing in QB64 folder
  15. PRINT "Tree created."
  16. PRINT USING "##.##### seconds creating and sorting tree."; TIMER - t#
  17. PRINT "Showing Tree"
  18. FOR i = 0 TO UBOUND(Tree) 'show tree
  19.     PRINT _TRIM$(STR$(i)); ": "; Tree(i)
  20.     IF i MOD 40 = 0 AND i > 0 THEN INPUT "Press enter to continue... "; w$: CLS
  21.  
  22.  
  23. SUB GetSubDirs (SearchDirectory AS STRING)
  24.     CONST IS_DIR = 1
  25.     DIM flags AS LONG, file_size AS LONG, length, nam$
  26.     IF load_dir(SearchDirectory + CHR$(0)) THEN
  27.         DO
  28.             length = has_next_entry
  29.             IF length > -1 THEN
  30.                 nam$ = SPACE$(length)
  31.                 get_next_entry nam$, flags, file_size
  32.                 IF RIGHT$(nam$, 1) <> "." AND RIGHT$(nam$, 2) <> ".." THEN
  33.                     IF flags = IS_DIR OR _DIREXISTS(SearchDirectory + "\" + nam$) THEN
  34.                         REDIM _PRESERVE Tree(UBOUND(Tree) + 1)
  35.                         Tree(UBOUND(Tree)) = SearchDirectory + "\" + nam$
  36.                     END IF
  37.                 END IF
  38.             END IF
  39.         LOOP UNTIL length = -1
  40.     ELSE
  41.         PRINT "Dir not loaded"
  42.     END IF
  43.     close_dir
  44.  
  45. SUB MakeTree (Dir$)
  46.     DIM OnDir AS LONG, gap AS LONG, i AS LONG, swapped AS LONG
  47.     REDIM Tree(0) AS STRING
  48.     Tree(0) = Dir$
  49.     DO
  50.         GetSubDirs Tree(OnDir)
  51.         OnDir = OnDir + 1
  52.     LOOP UNTIL OnDir > UBOUND(Tree)
  53.     gap = UBOUND(Tree)
  54.     DO
  55.         gap = 10 * gap \ 13
  56.         IF gap < 1 THEN gap = 1
  57.         i = 0
  58.         swapped = 0
  59.         DO
  60.             IF Tree(i) > Tree(i + gap) THEN
  61.                 SWAP Tree(i), Tree(i + gap)
  62.                 swapped = -1
  63.             END IF
  64.             i = i + 1
  65.         LOOP UNTIL i + gap > UBOUND(Tree)
  66.     LOOP UNTIL gap = 1 AND swapped = 0
  67.  
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Development of a program for automatic search for music and movies
« Reply #61 on: June 27, 2020, 12:51:45 am »
List retrieved and sorted in about 1 second, on my PC.
@SMcNeill
Steve,
I was timing the printing of the output as well. Not only the creation of the array. When I run your code and put the timers in the same spot as I did for bplus and myself, I get 4.301 seconds.
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Development of a program for automatic search for music and movies
« Reply #62 on: June 27, 2020, 12:52:49 am »
Your logic is showing a file in the QB64 directory as a folder but is just a file without an extension.

\internal\c\c_compiler\licenses\libffi\LICENSE

Running on my machine, I'm not getting this false result.  What system are you running under?  Is this difference something in 32-bit versions of QB64 vs 64-bit?  Linux vs Windows?  On Win 10, QB64x64, I'm not seeing LICENSE in the file listing.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Development of a program for automatic search for music and movies
« Reply #63 on: June 27, 2020, 12:53:40 am »
Running on my machine, I'm not getting this false result.  What system are you running under?  Is this difference something in 32-bit versions of QB64 vs 64-bit?  Linux vs Windows?  On Win 10, QB64x64, I'm not seeing LICENSE in the file listing.
I'm running QB64 x64 v1.4 on Windows 10 build 1909
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Development of a program for automatic search for music and movies
« Reply #64 on: June 27, 2020, 12:56:39 am »
@SMcNeill
Steve,
I was timing the printing of the output as well. Not only the creation of the array. When I run your code and put the timers in the same spot as I did for bplus and myself, I get 4.301 seconds.

I'm still only getting about 1.2 seconds to get, sort, and print the listing.  I have no idea why it'd take 3+ seconds to print the results on your machine.  Something seems off there.

Code: QB64: [Select]
  1. DEFLNG A-Z
  2.     FUNCTION load_dir& (s AS STRING)
  3.     FUNCTION has_next_entry& ()
  4.     SUB close_dir ()
  5.     SUB get_next_entry (s AS STRING, flags AS LONG, file_size AS LONG)
  6.  
  7.  
  8. SCREEN _NEWIMAGE(1280, 740, 32)
  9. _DELAY .25
  10. DIM cd$, i, w$
  11.  
  12. PRINT "Creating tree."
  13. t# = TIMER(0.001)
  14. MakeTree _CWD$ 'testing in QB64 folder
  15. PRINT "Showing Tree"
  16. FOR i = 0 TO UBOUND(Tree) 'show tree
  17.     PRINT i; ": "; Tree(i)
  18. PRINT USING "##.##### seconds creating, printing, and sorting tree."; TIMER - t#
  19.  
  20.  
  21. SUB GetSubDirs (SearchDirectory AS STRING)
  22.     CONST IS_DIR = 1
  23.     DIM flags AS LONG, file_size AS LONG, length, nam$
  24.     IF load_dir(SearchDirectory + CHR$(0)) THEN
  25.         DO
  26.             length = has_next_entry
  27.             IF length > -1 THEN
  28.                 nam$ = SPACE$(length)
  29.                 get_next_entry nam$, flags, file_size
  30.                 IF RIGHT$(nam$, 1) <> "." AND RIGHT$(nam$, 2) <> ".." THEN
  31.                     IF flags = IS_DIR OR _DIREXISTS(SearchDirectory + "\" + nam$) THEN
  32.                         REDIM _PRESERVE Tree(UBOUND(Tree) + 1)
  33.                         Tree(UBOUND(Tree)) = SearchDirectory + "\" + nam$
  34.                     END IF
  35.                 END IF
  36.             END IF
  37.         LOOP UNTIL length = -1
  38.     ELSE
  39.         PRINT "Dir not loaded"
  40.     END IF
  41.     close_dir
  42.  
  43. SUB MakeTree (Dir$)
  44.     DIM OnDir AS LONG, gap AS LONG, i AS LONG, swapped AS LONG
  45.     REDIM Tree(0) AS STRING
  46.     Tree(0) = Dir$
  47.     DO
  48.         GetSubDirs Tree(OnDir)
  49.         OnDir = OnDir + 1
  50.     LOOP UNTIL OnDir > UBOUND(Tree)
  51.     gap = UBOUND(Tree)
  52.     DO
  53.         gap = 10 * gap \ 13
  54.         IF gap < 1 THEN gap = 1
  55.         i = 0
  56.         swapped = 0
  57.         DO
  58.             IF Tree(i) > Tree(i + gap) THEN
  59.                 SWAP Tree(i), Tree(i + gap)
  60.                 swapped = -1
  61.             END IF
  62.             i = i + 1
  63.         LOOP UNTIL i + gap > UBOUND(Tree)
  64.     LOOP UNTIL gap = 1 AND swapped = 0
  65.  

SS.png
* SS.png (Filesize: 428.89 KB, Dimensions: 1920x1040, Views: 276)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Development of a program for automatic search for music and movies
« Reply #65 on: June 27, 2020, 12:58:10 am »
I'm still only getting about 1.2 seconds to get, sort, and print the listing.  I have no idea why it'd take 3+ seconds to print the results on your machine.  Something seems off there.
I'm placing the timer variable at the beginning of the program. First line for both mine and bplus's. Then showing the time for everything being completed at the end after everything has been printed completely. If I run your code you just posted I still get an output slower than both mine and bplus's at a speed of 3.709 seconds. I also have many more directories than you and bplus do (about 1300) , so that's why I'm in the 3 seconds + range on my PC. This time, running your code, your program failed to find two directories:
internal\c\c_compiler\x86_64-w64-mingw32\include\GL
internal\c\c_compiler\x86_64-w64-mingw32\lib\ldscripts

It found them, but for some reason, the strings are showing as being different from the ones that I have. If I try finding the directory in your file it can't find it unless I trim off some of the directory. Hmm. I'll need to investigate further. When I compare your file and mine, it shows that it can't find those two directories in your file. Something is definitely different about the characters. EDIT: After reinvestigating and sorting your file with PowerShell so ours would have the same structure, it no longer showed those two missing when comparing them. The way your program gets the directory string must have some different characters in there from what PowerShell provides. I'm exporting my strings as ASCII from PowerShell. What encoding are your strings?

And, your program still finds the libffi\LICENSE file as a folder.
Also, the sort isn't sorting in the order I would expect. After InForm I would expect internal to be next as it is the next folder alphabetically, even in File Explorer. However, yours goes to LICENSE then jumps to my folder called QB64Library then goes to internal. I guess you are sorting alphabetically by capital letters first, then lowercase?
« Last Edit: June 27, 2020, 01:34:11 am by SpriggsySpriggs »
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Development of a program for automatic search for music and movies
« Reply #66 on: June 27, 2020, 01:34:04 am »
\internal\c\c_compiler\licenses\libffi\LICENSE doesn't come up in the listing as a file for me.  Perhaps you could do a manual check and see what QB64 calls it on your machine.

Code: [Select]
IF _DIREXISTS("internal\c\c_compiler\licenses\libffi\LICENSE") THEN
    PRINT "QB64 is recognizing this as a directory on my PC, for some odd reason."
ELSE
    PRINT "It either doesn't exist, as I typed it in, or else QB64 recognizes it as a file."
    IF _FILEEXISTS("internal\c\c_compiler\licenses\libffi\LICENSE") THEN
        PRINT "QB64 found it, recognized it as a file."
    ELSE
        PRINT "File not found at all, as entered into the search parameters."
    END IF
END IF

We're relying on QB64 to basically tell us if it's a file or a directory, and for some odd reason, you see to be generating a false positive on your machine.  I dunno if that's a glitch in the version of QB64 you're using, something odd that Windows is reporting wrong, or where the problem actually comes from, but it's not from the direntry routines themselves. 



As for sorting, I just did a basic combsort alphabetically, which places uppercase separate from lowercase.  If you want to sort without comparing case, change the sort to using _STRICMP instead of the simple > which I tossed in there.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Development of a program for automatic search for music and movies
« Reply #67 on: June 27, 2020, 01:39:22 am »
As for sorting, I just did a basic combsort alphabetically, which places uppercase separate from lowercase.  If you want to sort without comparing case, change the sort to using _STRICMP instead of the simple > which I tossed in there.  ;)
I did this and it sorts incorrectly once more, placing some subdirectories in the wrong spots on the tree. For instance, this is how it should sort:
x86_64-w64-mingw32\lib
x86_64-w64-mingw32\lib\ldscripts
x86_64-w64-mingw32\lib32\

How your program sorts using _STRICMP:
x86_64-w64-mingw32\lib
x86_64-w64-mingw32\lib32\
x86_64-w64-mingw32\lib\ldscripts

Also, see below from testing your _DIREXISTS for that file/folder issue: (And yes, it is a file. I opened it in Notepad to be sure)
 
results from direxists.png

The issue appears to be your flag IS_DIR. If I remove that from the check to see if it is a directory, it doesn't show up. It only appears if I leave the flag as an argument to your IF statement for determining a directory.
« Last Edit: June 27, 2020, 01:49:06 am by SpriggsySpriggs »
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Development of a program for automatic search for music and movies
« Reply #68 on: June 27, 2020, 01:41:56 am »
Well the disadvantage of not using CHDIR is having to sort later?

It's not the lack of CHDIR which dictates the order which mine shows up in -- its the fact that mine's a non-recursive routine, compared to yours.  Mine does one whole level first, before going to the next depth of directories and then doing them next.  ;)

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline codeguy

  • Forum Regular
  • Posts: 174
    • View Profile
Re: Development of a program for automatic search for music and movies
« Reply #69 on: June 27, 2020, 03:59:16 am »
When you can match or beat Search Everything at this, let me know. https://www.voidtools.com/.

Modified your code slightly, Steve
Code: [Select]
DEFLNG A-Z
DECLARE CUSTOMTYPE LIBRARY ".\direntry"
    FUNCTION load_dir& (s AS STRING)
    FUNCTION has_next_entry& ()
    SUB close_dir ()
    SUB get_next_entry (s AS STRING, flags AS LONG, file_size AS LONG)
END DECLARE

REDIM SHARED Tree(0) AS STRING

SCREEN _NEWIMAGE(1280, 740, 32)
_DELAY .25
_SCREENMOVE 80, 0
DIM cd$, i, w$

PRINT "Creating tree."
t# = TIMER(0.001)
MakeTree _CWD$ 'testing in QB64 folder
PRINT "Tree created."
PRINT USING "##.##### seconds creating and sorting tree."; TIMER - t#
SLEEP
CLS
_KEYCLEAR
PRINT "Showing Tree"
FOR i = 0 TO UBOUND(Tree) 'show tree
    PRINT _TRIM$(STR$(i)); ": "; Tree(i)
    IF i MOD 40 = 0 AND i > 0 THEN INPUT "Press enter to continue... "; w$: CLS
NEXT


SUB GetSubDirs (SearchDirectory AS STRING)
    CONST IS_DIR = 1
    DIM flags AS LONG, file_size AS LONG, length, nam$
    IF load_dir(SearchDirectory + CHR$(0)) THEN
        DO
            length = has_next_entry
            IF length > -1 THEN
                nam$ = SPACE$(length)
                get_next_entry nam$, flags, file_size
                IF RIGHT$(nam$, 1) <> "." AND RIGHT$(nam$, 2) <> ".." THEN
                    IF flags = IS_DIR OR _DIREXISTS(SearchDirectory + "\" + nam$) THEN
                        REDIM _PRESERVE Tree(UBOUND(Tree) + 1)
                        Tree(UBOUND(Tree)) = SearchDirectory + "\" + nam$
                    END IF
                END IF
            END IF
        LOOP UNTIL length = -1
    ELSE
        PRINT "Dir not loaded"
    END IF
    close_dir
END SUB

SUB MakeTree (Dir$)
    DIM OnDir AS LONG
    REDIM Tree(0) AS STRING
    Tree(0) = Dir$
    DO
        GetSubDirs Tree(OnDir)
        OnDir = OnDir + 1
    LOOP UNTIL OnDir > UBOUND(Tree)
    QuickSortIterativeString Tree(), LBOUND(tree), OnDir - 1, 1
    'gap = UBOUND(Tree)
    'DO
    '    gap = 10 * gap \ 13
    '    IF gap < 1 THEN gap = 1
    '    i = 0
    '    swapped = 0
    '    DO
    '        IF Tree(i) > Tree(i + gap) THEN
    '            SWAP Tree(i), Tree(i + gap)
    '            swapped = -1
    '        END IF
    '        i = i + 1
    '    LOOP UNTIL i + gap > UBOUND(Tree)
    'LOOP UNTIL gap = 1 AND swapped = 0
END SUB

SUB QuickSortIterativeString (CGSortLibArr() AS String, QSIStart AS LONG, QSIFinish AS LONG, order&)
    DIM QSI_Local_Compare AS String '* MUST be same type as element of CGSortLibArr()
    '* These MUST be the appropriate type for the range being sorted
    DIM QSI_Local_I AS LONG
    DIM QSI_local_J AS LONG
    DIM QSI_Local_Hi AS LONG
    DIM QSI_Local_Low AS LONG
    DIM QSI_Local_Mid AS LONG
    '****************************************************************

    '* Integer suffices for QSI_Local_MinStackPtr unless you're sorting more than 2^32767 elements.
    DIM QSI_Local_MinStackPtr AS INTEGER: QSI_Local_MinStackPtr = 0
    DIM QSI_Local_QSI_local_CurrentStackPtr AS INTEGER: QSI_Local_QSI_local_CurrentStackPtr = 0
    DIM QSI_Local_FinishMinusStart AS LONG: QSI_Local_FinishMinusStart = QSIFinish - QSIStart
    DIM QSI_local_Remainder AS INTEGER

    '* yes, the equation log(QSIfinish-QSIstart)/log(2)+1 works too
    DO
        QSI_local_Remainder = QSI_Local_FinishMinusStart - (2 * INT(QSI_Local_FinishMinusStart / 2))
        QSI_Local_FinishMinusStart = (QSI_Local_FinishMinusStart - QSI_local_Remainder) / 2
        QSI_Local_MinStackPtr = QSI_Local_MinStackPtr + 1
    LOOP UNTIL QSI_Local_FinishMinusStart < 1

    '* MUST be appropriate type to handle the range (QSIfinish-QSIstart) being sorted
    DIM QSI_LStack(0 TO QSI_Local_MinStackPtr, 0 TO 1) AS LONG

    QSI_local_CurrentStackPtr = 0
    QSI_LStack(QSI_local_CurrentStackPtr, 0) = QSIStart
    QSI_LStack(QSI_local_CurrentStackPtr, 1) = QSIFinish
    DO
        QSI_Local_Low = QSI_LStack(QSI_local_CurrentStackPtr, 0)
        QSI_Local_Hi = QSI_LStack(QSI_local_CurrentStackPtr, 1)
        DO
            QSI_Local_I = QSI_Local_Low
            QSI_local_J = QSI_Local_Hi
            QSI_Local_Mid = QSI_Local_Low + (QSI_Local_Hi - QSI_Local_Low) \ 2
            QSI_Local_Compare = CGSortLibArr(QSI_Local_Mid)
            SELECT CASE order&
                CASE 1
                    DO
                        DO WHILE CGSortLibArr(QSI_Local_I) < QSI_Local_Compare
                            QSI_Local_I = QSI_Local_I + 1
                        LOOP
                        DO WHILE CGSortLibArr(QSI_local_J) > QSI_Local_Compare
                            QSI_local_J = QSI_local_J - 1
                        LOOP
                        IF QSI_Local_I <= QSI_local_J THEN
                            SWAP CGSortLibArr(QSI_Local_I), CGSortLibArr(QSI_local_J)
                            QSI_Local_I = QSI_Local_I + 1
                            QSI_local_J = QSI_local_J - 1
                        END IF
                    LOOP UNTIL QSI_Local_I > QSI_local_J
                CASE ELSE
                    DO
                        DO WHILE CGSortLibArr(QSI_Local_I) > QSI_Local_Compare
                            QSI_Local_I = QSI_Local_I + 1
                        LOOP
                        DO WHILE CGSortLibArr(QSI_local_J) < QSI_Local_Compare
                            QSI_local_J = QSI_local_J - 1
                        LOOP
                        IF QSI_Local_I <= QSI_local_J THEN
                            SWAP CGSortLibArr(QSI_Local_I), CGSortLibArr(QSI_local_J)
                            QSI_Local_I = QSI_Local_I + 1
                            QSI_local_J = QSI_local_J - 1
                        END IF
                    LOOP UNTIL QSI_Local_I > QSI_local_J
            END SELECT
            IF QSI_local_J - QSI_Local_Low < QSI_Local_Hi - QSI_Local_I THEN
                IF QSI_Local_I < QSI_Local_Hi THEN
                    QSI_LStack(QSI_local_CurrentStackPtr, 0) = QSI_Local_I
                    QSI_LStack(QSI_local_CurrentStackPtr, 1) = QSI_Local_Hi
                    QSI_local_CurrentStackPtr = QSI_local_CurrentStackPtr + 1
                END IF
                QSI_Local_Hi = QSI_local_J
            ELSE
                IF QSI_Local_Low < QSI_local_J THEN
                    QSI_LStack(QSI_local_CurrentStackPtr, 0) = QSI_Local_Low
                    QSI_LStack(QSI_local_CurrentStackPtr, 1) = QSI_local_J
                    QSI_local_CurrentStackPtr = QSI_local_CurrentStackPtr + 1
                END IF
                QSI_Local_Low = QSI_Local_I
            END IF
        LOOP WHILE QSI_Local_Low < QSI_Local_Hi
        QSI_local_CurrentStackPtr = QSI_local_CurrentStackPtr - 1
    LOOP UNTIL QSI_local_CurrentStackPtr < 0
END SUB
« Last Edit: June 27, 2020, 04:31:25 am by codeguy »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Development of a program for automatic search for music and movies
« Reply #70 on: June 27, 2020, 06:35:40 am »
Thank you all for your generous and successful help. How I want to continue: (if anyone has any suggestions on how to do it even better, write it here)

Now that we get the valid subdirectory names (and thank you again), I want to go through the individual folders and do list the files in each of them. If the file in a particular folder contains a name with a valid mask extension (this is at the beginning of this thread), the file name, including the path, will be added to the field.

After I get the valid names of all these files by mask, I will open each individual file for reading in binary mode and retrieve some information from the files (according to the file type), I will need to study the entries in the heads of specific files or, if someone knows about to any library that would do this for us, it would be another great easing of work. This information is:
- ID3 TAG - records in music files such as WAV, MP3, MP2, MP4 (I have already written this program, but it does not support all possible tags, it will need a heavy upgrade), but it can extract a photo from the file, if it is attached,
- sound length (this is the simplest, QB64 returns it to us with its own function)
- sound format (in some music formats it will be a purely sadomasochistic work)
- resolution (for video formats)
- number of frames per second
and other information, as required. Of course, this is a long job.

It would also like to set a rule for related photos right at the beginning. Suppose you want to add a photo of the band to the list (in this band folder), this photo will not be part of ID3. What rules do we set? Does the photo have to have the same name as its folder? Or will any photo in this folder be used? Or make it optional?

As you can see, there is still a lot.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Development of a program for automatic search for music and movies
« Reply #71 on: June 27, 2020, 10:10:21 am »
This information is:
- ID3 TAG - records in music files such as WAV, MP3, MP2, MP4 (I have already written this program, but it does not support all possible tags, it will need a heavy upgrade), but it can extract a
Which tags do you already have code to get? Here is code I have for tags:
Code: QB64: [Select]
  1. SUB GetSongTags (OFile$)
  2.     g% = FREEFILE
  3.     OPEN OFile$ FOR BINARY AS #g%
  4.  
  5.     DIM Songname AS STRING * 30
  6.     DIM Artist AS STRING * 30
  7.     DIM Album AS STRING * 30
  8.     DIM Year AS STRING * 4
  9.     DIM position AS SINGLE
  10.  
  11.     position = LOF(g%) - 124
  12.     GET #g%, position, Songname
  13.     position = LOF(g%) - 94
  14.     GET #g%, position, Artist
  15.     position = LOF(g%) - 64
  16.     GET #g%, position, Album
  17.     position = LOF(g%) - 34
  18.     GET #g%, position, Year
  19.     CLOSE #g%
  20.     SongTitle$ = Songname
  21.     Caption(TitleLB) = "Title: " + (Songname)
  22.     Caption(ArtistLB) = "Artist: " + (Artist)
  23.     Caption(AlbumLB) = "Album: " + (Album)
  24.     Caption(YearLB) = "Year: " + (Year)
« Last Edit: June 27, 2020, 10:30:44 am by SpriggsySpriggs »
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Development of a program for automatic search for music and movies
« Reply #72 on: June 27, 2020, 11:19:13 am »
Here is the timings I get on my Windows 10 System (not brand new) putting everyone's in Console window and timing from start to print of listing.

Did you guys figure out already why Steve shows an extra folder?

BTW Steve's sorting is case sensitive and Windows is not.

 
Whose is fastest whose is accurate.PNG


« Last Edit: June 27, 2020, 11:27:54 am by bplus »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Development of a program for automatic search for music and movies
« Reply #73 on: June 27, 2020, 11:23:48 am »
Here is the timings I get on my Windows 10 System (not brand new) putting everyone's in Console window and timing from start to print of listing.

Did you guys figure out already why Steve shows an extra folder?

 
Whose is fastest whose is accurate.PNG

@bplus
As for the speed, less directories will mean that your function will be faster than mine because I have to shell out to PowerShell. You can shave off some time by replacing my LTRIM$ and RTRIM with just _TRIM$. I shaved half a second with that. More directories, like the 1300 I have, will do better on mine because PowerShell quickly catches up on a larger process as proven by only having 3.109 seconds for 1300 directories where your computer spent that long on half that. As for the extra file, it's because of his flag IS_DIR. When I remove it, I don't have that file giving a false positive as a folder. It only shows up when I leave his flag in the statement.
« Last Edit: June 27, 2020, 11:32:29 am by SpriggsySpriggs »
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Development of a program for automatic search for music and movies
« Reply #74 on: June 27, 2020, 12:20:55 pm »
@bplus
As for the speed, less directories will mean that your function will be faster than mine because I have to shell out to PowerShell. You can shave off some time by replacing my LTRIM$ and RTRIM with just _TRIM$. I shaved half a second with that. More directories, like the 1300 I have, will do better on mine because PowerShell quickly catches up on a larger process as proven by only having 3.109 seconds for 1300 directories where your computer spent that long on half that. As for the extra file, it's because of his flag IS_DIR. When I remove it, I don't have that file giving a false positive as a folder. It only shows up when I leave his flag in the statement.

I just spent morning going over the tiny differences between Steve's, SUB GetSubDirs, the one that makes the calls to DirEntry.h

This line is very, very interesting!
Code: QB64: [Select]
  1. IF flags = IS_DIR OR _DIREXISTS(SearchDirectory + "\" + nam$) THEN
my recursive code really only needs If flags = IS_DIR (original it was IF flags AND IS_DIR, either way works)

Steves basically only needs IF _DIREXISTS(SearchDirectory + "\" + nam$) THEN
and the extra Directory, the false positive, is eliminated! without flags = IS_DIR
his won't even work without checking if _DIREXISTS, mine wont work without checking flags = IS_DIR

What is interesting is that when I don't double check _DIREXISTS(SearchDirectory + "\" + nam$)
my run time is significantly reduced!!! and I still get the 607 files on my system without the false positive.

I cut about a half second off my build and print time and if I can do this without changing directories (which should be quite possible) will have another big time savings.