Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Location
    Asturias, Spain
    Posts
    82

    how to get file extension

    hi to all again,
    i wonder if anyone can help me, i wassearching in teh forums but found nothing about that and i think its a easy thing but i dont know hoe to do...
    i explain: i want that when the user press a button load a mp3 or a vid, but for this i need to get the file.extension, wich i dont know how to do...

    now my code is: (but its wrong...)

    Code:
    file_path = Dialog.FileBrowse(true, "Abrir archivo..", _DesktopFolder, "Video Files (.avi, .mpg, .mpeg, .wmv, .asf, )|*.avi;*.mpg;*.mpeg;*.wmv;*.asf|All Files (*.*)|*.*|", "", "", false, true);
    --get file extension? i dont know how to do it...
    file = String.SplitPath(file_path);
    if (String.Lower(file.Filename..file.Extension)) == file_to_check_for then
            if file.extension == ".avi" or ".MPG" then
            --do whatelse
            else if file.extension == ".mp3" then
            --doanother thing
     end
    end
    end

    thanks for all

  2. #2
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Something like this should do:

    Code:
    file_path = Dialog.FileBrowse(true, "Abrir archivo..", _DesktopFolder, "Video Files (.avi, .mpg, .mpeg, .wmv, .asf, )|*.avi;*.mpg;*.mpeg;*.wmv;*.asf|All Files (*.*)|*.*|", "", "", false, true);
    if(file_path[1]~="CANCEL")then
    	if(File.DoesExist(file_path[1]))then
    		local extension=String.Lower(String.SplitPath(file_path[1]).Extension)
    		if(extension==".avi")or(extension=="mpg")then
    			--Actions for avi
    		elseif(extension==".mp3")then --Remember do type the extensions (only in this if statement) in lower case, because we are using String.Lower while we get the extension
    			--Actions for mpg
    	end
    end
    Last edited by Ulrich; 12-27-2008 at 07:50 AM.
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  3. #3
    Join Date
    Jan 2006
    Location
    Asturias, Spain
    Posts
    82

    thanks! ;)

    lol what a fast reply! THANKS mate

Similar Threads

  1. script to sort by file extension
    By qwerqwerqwer in forum AutoPlay Media Studio 7.5
    Replies: 2
    Last Post: 02-23-2008, 08:25 AM
  2. Are they bugs? (when opening a file in SUF 7.0.5.1)
    By Sergio_S in forum Setup Factory 7.0
    Replies: 0
    Last Post: 12-13-2006, 01:47 PM
  3. Zero K File Replacement
    By Terry Rasmussen in forum Setup Factory 6.0
    Replies: 0
    Last Post: 08-23-2004, 01:19 PM
  4. Can search allow manual browse even if file is found?
    By RichardShaw in forum Setup Factory 5.0
    Replies: 2
    Last Post: 08-28-2000, 06:08 PM
  5. Replies: 0
    Last Post: 08-17-2000, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts