searching for multiple file formats in directory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • gnetcanada
    Indigo Rose Customer
    • May 2003
    • 83

    searching for multiple file formats in directory

    Hi Guys,

    i designed an mp3 player and used some code from another autplay app posted here, anyway, i want it to search the directory selectted for mp3, wma, ogg and wav file formats not just mp3. I have attached the code below, what would i have to do to allow it to search for multiple formats at the same time and add them to the table?

    numitems = ListBox.GetCount("Playlist");
    myfolder = Shell.GetFolder(SHF_MYDOCUMENTS);
    ssfolder = Dialog.FolderBrowse("Select A Folder To Add", myfolder);
    if (ssfolder ~= "CANCEL") and (ssfolder ~= "") then
    subfolders = Dialog.Message("Recurse Subfolders", "Do you want to include subfolders", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON2)
    if (subfolders == IDYES) then
    subfolder = true
    else
    subfolder = false
    end
    file_table = File.Find(ssfolder, "*.mp3", subfolder, false, nil);
    if (file_table == nil) then
    Dialog.Message("Error", "There were no audio files in the selected Directory. Please select a directory that contains audio files", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
    dirselect = "NO";
    else
    file_count = Table.Count(file_table);
    ctr = 1;
    dirselect = "YES";
    StatusDlg.SetMeterRange("1", file_count);
    StatusDlg.SetTitle("Please wait while your audio files are loaded.");
    StatusDlg.Show(MB_ICONNONE, false);
    for i,file in file_table do
    videonametable = String.SplitPath(file);
    videoname = videonametable.Filename;
    result = ListBox.AddItem("Playlist", videoname, file);
    StatusDlg.SetMeterPos(i);
    end
    StatusDlg.Hide();
    end
    end
    if numitems == 0 then
    ListBox.SelectItem("Playlist", 1);
    end
  • gallurt
    Forum Member
    • Oct 2006
    • 8

    #2
    please how
    To modify code to look for search in " \\Autoplay\\Docs".

    and imput

    sorry by my bad engish

    Code:
    -- Was the Enter key pressed?  If so, continue on...
    if e_Key == 13 then
    
    
    numitems = ListBox.GetCount("ListBox1");
    myfolder = Shell.GetFolder(SHF_MYDOCUMENTS);
    ssfolder = [COLOR="Red"]File.Find("AutoPlay//Docs", "*.txt", false, true, nil, nil)[/COLOR]
    subfolders = Dialog.Message("Recurse Subfolders", "Do you want to include subfolders", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON2)
    if (subfolders == IDYES) then
    subfolder = true
    else
    subfolder = false
    end
    file_table = File.Find(ssfolder, "*.*", subfolder, false, nil);
    if (file_table == nil) then
    Dialog.Message("Error", "There were no audio files in the selected Directory. Please select a directory that contains audio files", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
    dirselect = "NO";
    else
    file_count = Table.Count(file_table);
    ctr = 1;
    dirselect = "YES";
    StatusDlg.SetMeterRange("1", file_count);
    StatusDlg.SetTitle("Please wait while your audio files are loaded.");
    StatusDlg.Show(MB_ICONNONE, false);
    for i,file in file_table do
    videonametable = String.SplitPath(file);
    videoname = videonametable.Filename;
    result = ListBox.AddItem("ListBox2", videoname, file);
    StatusDlg.SetMeterPos(i);
    end
    StatusDlg.Hide();
    end
    end
    if numitems == 0 then
    ListBox.SelectItem("ListBox2", 1);
    end
    end

    Comment

    • longedge
      Indigo Rose Customer
      • Aug 2003
      • 2498

      #3
      If you use the global variable _SourceFolder that will always refer to the location that your project is running from and then you can concatenate folders beneath that, so setting a variable -

      docsfolder = _SourceFolder.."\\Autoplay\\Docs"

      will give you the Docs folder.

      Comment

      • gallurt
        Forum Member
        • Oct 2006
        • 8

        #4
        I have proven but I have not obtained it.
        Attached Files

        Comment

        • longedge
          Indigo Rose Customer
          • Aug 2003
          • 2498

          #5
          I'm afraid I don't have AMS6 - this part of the forum is for AMS5

          Comment

          • gallurt
            Forum Member
            • Oct 2006
            • 8

            #6
            thanks for all

            Comment

            Working...
            X