Announcement

Collapse
No announcement yet.

find audio files and create table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • find audio files and create table

    hello, i need little help, ive got some pictures for example:
    Code:
     PictureTable = {
    "AutoPlay\\Images\\Teoriis Biletebi\\1konvencia\\62.png",
    "AutoPlay\\Images\\Teoriis Biletebi\\3mafrtxilebeli\\628.png",
    "AutoPlay\\Images\\Teoriis Biletebi\\1konvencia\\889.png",
    "AutoPlay\\Images\\Teoriis Biletebi\\29samedicino\\505.png",
    "AutoPlay\\Images\\Teoriis Biletebi\\21rkinigza\\430.png",
    "AutoPlay\\Images\\Teoriis Biletebi\\29samedicino\\915.png"
    }
    also ive got audio files with exact same name but in different location, so i want to find those audio files(starting location is here "\AutoPlay\Images\Teoriis Biletebi")
    and create txt document with full addresses,
    my knowledge is poor with "for loop" code.. (((
    i tried to take this table "PictureTable" then split path for file name and then use "File.Find" option, but i cant make it as table :(

  • #2
    Hello, friend, you can try this ..

    Write this code in the page ON SHOW

    Code:
    myPlayListFolder = _SourceFolder .. "\\AutoPlay\\PlayList";
    bFolderFound = Folder.DoesExist(myPlayListFolder);
    if bFolderFound==false then
    Folder.Create(myPlayListFolder);
    else
    end
    
    tPlayList = File.Find(myPlayListFolder, "*.mp4", false, false, nil, nil);
    if tPlayList then
    [B][COLOR=#2ecc71]--do the following for each file:[/COLOR][/B]
    for j,file_path in pairs(tPlayList) do
    [B][COLOR=#2ecc71]--add the item to the listbox, with the name visible and path as data[/COLOR][/B]
    tbFilePath = String.SplitPath(file_path);
    sFile = tbFilePath.Filename;
    ListBox.AddItem("ListBox2", sFile, file_path);
    end
    end
    Use to write to text file

    Code:
    function writePlayList()
    for i=1,nFiles do
    sData = ListBox.GetItemData("ListBox1", i);
    strOut = sData.."\r\n";
    TextFile.WriteFromString(myPlayListFolder.."\\"..s PlayList..".txt", strOut, true);
    
    end
    return
    end
    Another way
    -- a handy function

    Code:
    function FindExtensions(sFolder, tExt)
    local tAllFiles={}
    for i, sExt in pairs(tExt) do
    tSearch = File.Find(sFolder, "*."..sExt, true, false, nil);
    if tSearch then
    for k, sFile in pairs(tSearch) do
    tAllFiles[Table.Count(tAllFiles)+1]=sFile
    end
    end
    end
    if Table.Count(tAllFiles) >0 then
    return tAllFiles
    else
    return nil
    end
    end
    -- Example Usage
    Code:
    local tExt={"jpg", "bmp", "png", "gif", "ico"}[COLOR=#2ecc71]--Include file extensioons here eg mp4 etc[/COLOR]
    local sFolder=_SourceFolder .. "\\AutoPlay\\Images"[COLOR=#2ecc71]--Folder tro your files[/COLOR]
    
    local tAllFiles=FindExtensions(sFolder, tExt)
    if tAllFiles then
    Debug.ShowWindow()
    for i, sFile in pairs(tAllFiles) do
    Debug.Print(sFile.."\r\n")
    end
    end
    Also here is an example apz you can play with ....

    listbox-textfile-imagesearch-drilldown.apz
    Cheers

    Comment


    • #3
      Originally posted by colc View Post
      Hello, friend, you can try this ..

      Write this code in the page ON SHOW

      Code:
      myPlayListFolder = _SourceFolder .. "\\AutoPlay\\PlayList";
      bFolderFound = Folder.DoesExist(myPlayListFolder);
      if bFolderFound==false then
      Folder.Create(myPlayListFolder);
      else
      end
      
      tPlayList = File.Find(myPlayListFolder, "*.mp4", false, false, nil, nil);
      if tPlayList then
      [B][COLOR=#2ecc71]--do the following for each file:[/COLOR][/B]
      for j,file_path in pairs(tPlayList) do
      [B][COLOR=#2ecc71]--add the item to the listbox, with the name visible and path as data[/COLOR][/B]
      tbFilePath = String.SplitPath(file_path);
      sFile = tbFilePath.Filename;
      ListBox.AddItem("ListBox2", sFile, file_path);
      end
      end
      Use to write to text file

      Code:
      function writePlayList()
      for i=1,nFiles do
      sData = ListBox.GetItemData("ListBox1", i);
      strOut = sData.."\r\n";
      TextFile.WriteFromString(myPlayListFolder.."\\"..s PlayList..".txt", strOut, true);
      
      end
      return
      end
      Another way
      -- a handy function

      Code:
      function FindExtensions(sFolder, tExt)
      local tAllFiles={}
      for i, sExt in pairs(tExt) do
      tSearch = File.Find(sFolder, "*."..sExt, true, false, nil);
      if tSearch then
      for k, sFile in pairs(tSearch) do
      tAllFiles[Table.Count(tAllFiles)+1]=sFile
      end
      end
      end
      if Table.Count(tAllFiles) >0 then
      return tAllFiles
      else
      return nil
      end
      end
      -- Example Usage
      Code:
      local tExt={"jpg", "bmp", "png", "gif", "ico"}[COLOR=#2ecc71]--Include file extensioons here eg mp4 etc[/COLOR]
      local sFolder=_SourceFolder .. "\\AutoPlay\\Images"[COLOR=#2ecc71]--Folder tro your files[/COLOR]
      
      local tAllFiles=FindExtensions(sFolder, tExt)
      if tAllFiles then
      Debug.ShowWindow()
      for i, sFile in pairs(tAllFiles) do
      Debug.Print(sFile.."\r\n")
      end
      end
      Also here is an example apz you can play with ....

      [ATTACH]n305448[/ATTACH]
      Cheers

      thanks for your reply, i need to do function like this
      Code:
       desktopfolder = Shell.GetFolder(SHF_DESKTOP);
      
      misamartebiTST = {
      "AutoPlay\\Images\\Teoriis Biletebi\\1konvencia\\62.png",
      "AutoPlay\\Images\\Teoriis Biletebi\\3mafrtxilebeli\\628.png",
      "AutoPlay\\Images\\Teoriis Biletebi\\1konvencia\\889.png",
      "AutoPlay\\Images\\Teoriis Biletebi\\29samedicino\\505.png",
      "AutoPlay\\Images\\Teoriis Biletebi\\21rkinigza\\430.png",
      "AutoPlay\\Images\\Teoriis Biletebi\\29samedicino\\915.png"
      }
      
      
      for j,Names in pairs(misamartebiTST) do
      tFilePath = String.SplitPath(Names);
      sFile = tFilePath.Filename;
      Founded = File.Find("AutoPlay\\Images\\Teoriis Biletebi", sFile..".wav", true, false, nil, nil);
      
      for j,Filess in pairs(Founded) do
      TextFile.WriteFromString(desktopfolder.."\\TEST.tx t", Filess.."\r\n", true);
      end
      end
      to find WAV files with name (62,628,889,505,430,915) , but it doesnt work, all i get is txt doc with 3 WAV (

      AutoPlay\Images\Teoriis Biletebi\1konvencia\Exp\62.wav
      AutoPlay\Images\Teoriis Biletebi\3mafrtxilebeli\Exp\628.wav
      AutoPlay\Images\Teoriis Biletebi\1konvencia\Exp\889.wav

      )
      but it must be 6 line of address, also i get this error message
      Click image for larger version

Name:	Screenshot_1.jpg
Views:	233
Size:	20.3 KB
ID:	305451

      Comment


      • #4
        Hi, first start to change
        Code:
         TextFile.WriteFromString(desktopfolder.."\\TEST.tx t", Filess.."\r\n", true);
        into
        Code:
        TextFile.WriteFromString(desktopfolder.."\\TEST.txt", Filess.."\r\n", true);
        so "tx t" wil be "txt".

        and are you sure that the file 505.wav does exist in the folder "29samedicino" ?

        what line is Line 18 under xButton1?
        That is the line with the error.

        mario
        programming is very easy, just put the characters in the right order....

        Comment


        • #5
          Originally posted by ovm View Post
          Hi, first start to change
          Code:
           TextFile.WriteFromString(desktopfolder.."\\TEST.tx t", Filess.."\r\n", true);
          into
          Code:
          TextFile.WriteFromString(desktopfolder.."\\TEST.txt", Filess.."\r\n", true);
          so "tx t" wil be "txt".

          and are you sure that the file 505.wav does exist in the folder "29samedicino" ?

          what line is Line 18 under xButton1?
          That is the line with the error.

          mario
          extention corrected, file does exist, and this is the full code of that xbutton.

          Code:
          desktopfolder = Shell.GetFolder(SHF_DESKTOP);
          misamartebiTST = { "AutoPlay\\Images\\Teoriis Biletebi\\1konvencia\\62.png",
          "AutoPlay\\Images\\Teoriis Biletebi\\3mafrtxilebeli\\628.png",
          "AutoPlay\\Images\\Teoriis Biletebi\\1konvencia\\889.png",
          "AutoPlay\\Images\\Teoriis Biletebi\\29samedicino\\505.png",
          "AutoPlay\\Images\\Teoriis Biletebi\\21rkinigza\\430.png",
          "AutoPlay\\Images\\Teoriis Biletebi\\29samedicino\\915.png"
          }
          for j,Names in pairs(misamartebiTST) do
          tFilePath = String.SplitPath(Names);
          sFile = tFilePath.Filename;
          Founded = File.Find("AutoPlay\\Images\\Teoriis Biletebi", sFile..".wav", true, false, nil, nil);
          for j,Filess in pairs(Founded) do
          TextFile.WriteFromString(desktopfolder.."\\TEST.txt", Filess.."\r\n", true);
          end
          end
          i got it worked in a different way, thx anyway <3

          Comment


          • #6
            Sorry to get back late,
            Check this out
            Example.apz

            Comment


            • #7
              Originally posted by colc View Post
              Sorry to get back late,
              Check this out
              [ATTACH]n305455[/ATTACH]
              thank's for your reply. i already did it in a different way.
              thank you for your time!

              Comment


              • #8
                Hi koxera1, very useful,yes
                thanks

                Alain.

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎