darknezz21 Posted January 16, 2016 Share Posted January 16, 2016 I'm trying to remove the extensions of the files returned with _Filelistoarray but am not sure how to express this. Also tried _RecFileListToArray by Melba23 as suggested in the link I found below but I don't see an option for this functionality. Here is what Ive tried so far, any suggestions? ;Local $aFileList = _FileListToArray(@ScriptDir, "*.txt") Local $aFileList = _RecFileListToArray(@ScriptDir, "*.*", 0, 0, 0, 1, "*.au3", "") If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Display the results returned by _FileListToArray. _ArrayDisplay($aFileList, "$aFileList") MsgBox($MB_SYSTEMMODAL, "", $aFileList[1]) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 16, 2016 Moderators Share Posted January 16, 2016 darknezz21, The comment refers to excluding certain file extensions from the returned array - not removing the extensions from the returned files. My ChooseFileFolder UDF does have this functionality when displaying a file list (I use it when listing mp3 files) but that is not a lot of use to you. I think you are going to have to remove the extensions in a loop like this: #include <File.au3> Local $aFileList = _FileListToArrayRec(@ScriptDir, "*.*|*.au3", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_NOSORT) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Now loop and remove the extension For $i = 1 To $aFileList[0] $aFileList[$i] = StringRegExpReplace($aFileList[$i], "^.*\\|\..*$", "") Next _ArrayDisplay($aFileList, "$aFileList") MsgBox($MB_SYSTEMMODAL, "", $aFileList[1]) Note that the deprecated _RecFileListToArray UDF is now part of the standard UDFs (with a slightly different name) and has a different syntax for the excluded files and folders as you can see - look in the Help file for more details. M23 darknezz21 1 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...
darknezz21 Posted January 16, 2016 Author Share Posted January 16, 2016 (edited) I'm having trouble getting it to edit the .txt extensions off still. Here is basically what was tried. I also tried the .txt without the wildcard in front but it's the same. Local $aFileList = _RecFileListToArray(@ScriptDir, "*.*", 1, 1, 1, 1, "*.au3", "") $post = $aFileList[1] ; Now loop and remove the extension For $i = 1 To $post $aFileList[$i] = StringRegExpReplace($aFileList[$i], "*.txt", "") Next _ArrayDisplay($aFileList, "$aFileList") Edited January 16, 2016 by darknezz21 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 16, 2016 Moderators Share Posted January 16, 2016 darknezz21, Why are you still using my old UDF? As I explained above, it is now deprecated and you should use the standard _FileListToArrayRec UDF. And of course the RegEx will not work as you have coded it - the pattern will never match. If you leave the command exactly as I posted it will work. M23 darknezz21 1 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...
mikell Posted January 17, 2016 Share Posted January 17, 2016 Melba, $File = "C:\my.beloved.singer.mp3" $File = StringRegExpReplace($File, "^.*\\|\..*$", "") Msgbox(0,"", $File) May I suggest $File = StringRegExpReplace($File, '^.*\\|\.[^.]*$', "") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2016 Moderators Share Posted January 17, 2016 mikell, Of course you may - always ready to learn. 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...
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