richietheprogrammer Posted July 14, 2014 Share Posted July 14, 2014 Hey all, it's been a while Seems simple enough, but I can't figure out how to get started. I am looking to sort files inside sub folders by file type, so that when I do browse to the folders, the files are already sorted by type. Any help is appreciated! Cheers! Link to comment Share on other sites More sharing options...
AZJIO Posted July 14, 2014 Share Posted July 14, 2014 #include <File.au3> #include <Array.au3> $aFileList = _FileListToArray(@DesktopDir, '*', 1) ; $aFileList =_FileListToArray(@HomeDrive, '*', 1) If @error Then Exit MsgBox(0, "", '@error = ' & @error) Local $aFileList_2D[$aFileList[0] + 1][2] For $i = 1 To $aFileList[0] $aFileList_2D[$i][0] = $aFileList[$i] $aFileList_2D[$i][1] = StringRegExpReplace($aFileList[$i], '^(?:.+?)(?:\.([^.\\]+))?$', '\1') Next ; _ArrayDisplay($aFileList_2D,"$aFileList_2D") _ArraySort($aFileList_2D, 0, 1, 0, 1) For $i = 1 To $aFileList[0] $aFileList[$i] = $aFileList_2D[$i][0] Next _ArrayDisplay($aFileList, "$aFileList") richietheprogrammer 1 My other projects or all Link to comment Share on other sites More sharing options...
richietheprogrammer Posted July 14, 2014 Author Share Posted July 14, 2014 (edited) #include <File.au3> #include <Array.au3> $aFileList = _FileListToArray(@DesktopDir, '*', 1) ; $aFileList =_FileListToArray(@HomeDrive, '*', 1) If @error Then Exit MsgBox(0, "", '@error = ' & @error) Local $aFileList_2D[$aFileList[0] + 1][2] For $i = 1 To $aFileList[0] $aFileList_2D[$i][0] = $aFileList[$i] $aFileList_2D[$i][1] = StringRegExpReplace($aFileList[$i], '^(?:.+?)(?:\.([^.\\]+))?$', '\1') Next ; _ArrayDisplay($aFileList_2D,"$aFileList_2D") _ArraySort($aFileList_2D, 0, 1, 0, 1) For $i = 1 To $aFileList[0] $aFileList[$i] = $aFileList_2D[$i][0] Next _ArrayDisplay($aFileList, "$aFileList") Awesome, thank you. I am looking to browse all subfolders as well. Is that possible? Also, Is there anyway I can get the path in the second column? The path of each corresponding file? Thanks! Edited July 14, 2014 by richietheprogrammer Link to comment Share on other sites More sharing options...
mikell Posted July 14, 2014 Share Posted July 14, 2014 You should have a look at the helpfile before asking First try this $aFileList = _FileListToArray(@DesktopDir, '*', 1, 1) Then try _FileListToArrayRec() with the needed params richietheprogrammer 1 Link to comment Share on other sites More sharing options...
richietheprogrammer Posted July 14, 2014 Author Share Posted July 14, 2014 You should have a look at the helpfile before asking First try this $aFileList = _FileListToArray(@DesktopDir, '*', 1, 1) Then try _FileListToArrayRec() with the needed params Sorry about that, should have checked there first. I appreciate it. I will try to finish it and will post if I have more questions. Thanks! Link to comment Share on other sites More sharing options...
richietheprogrammer Posted July 15, 2014 Author Share Posted July 15, 2014 So I got the list to sort correctly, but is there a way to actually sort the files in all the folders, so that when I browse to them in explorer, they're all sorted? Thanks! Link to comment Share on other sites More sharing options...
BrewManNH Posted July 15, 2014 Share Posted July 15, 2014 Open Windows Explorer to any folder, set it up exactly how you'd like it to look, click the Tools menu, Folder Options, View tab, click the Apply to Folders button. richietheprogrammer 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
richietheprogrammer Posted July 15, 2014 Author Share Posted July 15, 2014 Ha, nice. No script needed afterall. Thank you! 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