Jump to content

How get file extension?


ZeR0
 Share

Recommended Posts

#include <File.au3>

$PATH = FileOpenDialog("PATH",@ScriptDir,"All (*.*)")
If Not @error Then
    Dim $szDrive, $szDir, $szFName, $szExt
    $PATH = _PathSplit($PATH,$szDrive,$szDir,$szFName,$szExt)
    MsgBox(0,"",$PATH[4])
EndIf

When the words fail... music speaks.

Link to comment
Share on other sites

$filed = FileOpenDialog ("", "", "All (*.*)")

MsgBox (0, "", GetFileExt($filed))

Func GetFileExt($file)
    Return StringRight($file, StringLen($file) - StringInStr($file, ".", 0, -1))
EndFunc  ;==>GetFileExt

Link to comment
Share on other sites

:) Anyone esle for the competition ? :o

Cheers, FireFox.

$CurrentFile = "C:\Directory\Directory2\FileNameHere.AnyExtensionLength"

For $YLoop = StringLen ($CurrentFile) to 1 Step -1
    If StringMid ($CurrentFile, $YLoop, 1) == "." Then
         $fl_Ext = StringMid ($CurrentFile, $YLoop)
         $YLoop = 1
    EndIf
Next

Result: $fl_Ext = ".AnyExtensionLength"

The problem with other suggestions:

1) "."s in Directory Name: "C:\Direct.ory\Ham\Cheese\FileName.ext"

2) Multiple "."s in filename: "This.is.my.file.name.bmp"

Edited by Harlequin

But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security. - U.S. Declaration of Independence

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...