ZeR0 Posted December 30, 2008 Share Posted December 30, 2008 Hi, i need help here... I coding something and i need get the extension of file, i check the help file, but i not have results... who can help me??? Link to comment Share on other sites More sharing options...
Tomb Posted December 30, 2008 Share Posted December 30, 2008 _PathSplit() Link to comment Share on other sites More sharing options...
Andreik Posted December 30, 2008 Share Posted December 30, 2008 #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 More sharing options...
FireFox Posted December 30, 2008 Share Posted December 30, 2008 (edited) quicker solution $extension = StringReplace(StringRight($path,4),".","") Cheers,FireFox. Edited December 30, 2008 by FireFox Link to comment Share on other sites More sharing options...
Andreik Posted December 30, 2008 Share Posted December 30, 2008 quicker solution $extension = StringReplace(StringRight($path,4),".","") Cheers,FireFox. I don't know what to say about this. Exists file extenstions with more then 4 chars. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Pain Posted December 30, 2008 Share Posted December 30, 2008 That will different result for .exe, .jpeg and .xhtml etc. Link to comment Share on other sites More sharing options...
FireFox Posted December 30, 2008 Share Posted December 30, 2008 (edited) @Andreik If you insist $split = StringSplit($path, "\") $name = StringSplit($path[$path[0]], ".") $ext = $name[2] Cheers, FireFox. Edited December 30, 2008 by FireFox Link to comment Share on other sites More sharing options...
system24 Posted December 31, 2008 Share Posted December 31, 2008 You could immediately split the path using "." as delimiter. $split = StringSplit($path, ".") $ext = $split[$split[0]] Velislav 1 [center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center] Link to comment Share on other sites More sharing options...
rasim Posted December 31, 2008 Share Posted December 31, 2008 $sFile = "c:\Program Files\AutoIt3\AutoIt3.chm" $sExt = StringRegExpReplace($sFile, "^.*\.", "") MsgBox(0, "Extension", $sExt) Link to comment Share on other sites More sharing options...
BrettF Posted December 31, 2008 Share Posted December 31, 2008 $filed = FileOpenDialog ("", "", "All (*.*)") MsgBox (0, "", GetFileExt($filed)) Func GetFileExt($file) Return StringRight($file, StringLen($file) - StringInStr($file, ".", 0, -1)) EndFunc ;==>GetFileExt AGlassman 1 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
FireFox Posted December 31, 2008 Share Posted December 31, 2008 Anyone esle for the competition ? Cheers, FireFox. Link to comment Share on other sites More sharing options...
Harlequin Posted December 31, 2008 Share Posted December 31, 2008 (edited) Anyone esle for the competition ? 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 December 31, 2008 by Harlequin DigitalFacade82 1 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now