legend Posted October 27, 2013 Share Posted October 27, 2013 Hello. How would I split it up, so I get a list of extensions to save the file as? instead of: txt,ini, it would be .txt .ini After that I need to get the extension with a msgbox, I don't need the file path, only the extension that the user selected, is that possible? I can think of a way of how that would be done, maybe someone knows? Link to comment Share on other sites More sharing options...
JohnOne Posted October 27, 2013 Share Posted October 27, 2013 FileSaveDialog() does the first bit. There are tons of examples on how to extract extension from path, who should perform the search? You will need to add a StringSplit()and a loop if multiple files are selected. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2013 Moderators Share Posted October 27, 2013 legend,You could write your own dialog. Here is a proof of concept script using my ChooseFileFolder UDF:expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include "ChooseFileFolder.au3" Global $aDrives = DriveGetDrive("ALL") Global $sDrives = "" For $i = 1 To $aDrives[0] ; Only display ready drives If DriveStatus($aDrives[$i] & '\') <> "NOTREADY" Then $sDrives &= "|" & StringUpper($aDrives[$i]) Next $sExt = "txt|ini" $sDef_Ext = "txt" $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xC4C4C4) GUICtrlCreateLabel("Choose Drive", 10, 10, 90, 20) $cCombo_Drive = GUICtrlCreateCombo("", 100, 10, 60, 20) GUICtrlSetData($cCombo_Drive, $sDrives) $cTreeView = GUICtrlCreateTreeView(10, 50, 200, 200) GUICtrlCreateLabel("Choose Drive", 10, 270, 90, 20) $cCombo_Ext = GUICtrlCreateCombo("", 100, 270, 60, 20) GUICtrlSetData($cCombo_Ext, $sExt, $sDef_Ext) GUISetState() ; Register UDF message handler _CFF_RegMsg() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo_Drive $sRoot = GUICtrlRead($cCombo_Drive) & "\" ; Create drive treeview and wait for a selection $sSel = _CFF_Embed($cTreeView, $sRoot, "*.*", 12) $sNew_Ext = GUICtrlRead($cCombo_Ext) $sCurr_Ext = StringRegExpReplace($sSel, "^.*\.", "") ; Change extension if required If $sCurr_Ext <> $sNew_Ext Then $sSel = StringReplace($sSel, "." & $sCurr_Ext, "." & $sNew_Ext) EndIf GUIDelete($hGUI) MsgBox($MB_SYSTEMMODAL, "Filename", $sSel) EndSwitch WEndPlease ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
l3ill Posted October 27, 2013 Share Posted October 27, 2013 This is one way of getting the ext used in a msg box, using iniwrite could list them for you. Local $var = FileSaveDialog("Your File", @DesktopDir & "\", "", 1) $ext = StringRight($var, 4) MsgBox(0, "File Extension is", $ext) But is sounds like you want this list in the FileSaveDialog built in. Kinda vague My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
JohnOne Posted October 27, 2013 Share Posted October 27, 2013 Totally misread question. Might be best to search web for registry key that holds local valid file extensions. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Guest Posted October 27, 2013 Share Posted October 27, 2013 my way to get the extension: $file = "bla.bla2s.extension" $FileExtension = StringSplit($file,".",1) $FileExtension = $FileExtension[$FileExtension[0]] MsgBox(0,"Test1",'The file extension is: "'&$FileExtension&'"') $file = "test.txt" $FileExtension = StringSplit($file,".",1) $FileExtension = $FileExtension[$FileExtension[0]] MsgBox(0,"Test2",'The file extension is: "'&$FileExtension&'"') Link to comment Share on other sites More sharing options...
JohnOne Posted October 27, 2013 Share Posted October 27, 2013 MsgBox(0,0,_Ext("P:\\ATH\TO\FILE.EXT")) Func _Ext($Path) Return StringRight($Path,StringLen($Path) - StringInStr($Path,'.', 0,-1)) EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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