qazwsx Posted July 23, 2007 Share Posted July 23, 2007 (edited) This small program cleans out your music folder. It deletes all files that are not .mp3. I use this to get rid of the album art that often comes with songs. This shrunk my music folder from 9 gigs to 4.5 and left all of my songs intact. WARNING IF YOU USE ITUNE YOUR SONGS MAY BE .MP4 You can stop this program at any time by pressing escape. Simply copy the script into your music folder and run it. It will delete itself when finished. It now support .mp3, mp4, and jpg, and has the option to save that extension or delete it. expandcollapse popup;music indexer HotKeySet("{esc}", "_exit") Global $var Global $search Global $ext Global $path Global $file Global $efile #include <GUIConstants.au3> $Form1 = GUICreate("Clean", 375, 186, -1, -1) $Button1 = GUICtrlCreateButton("Select Folder", 144, 8, 91, 33, 0) $Radio1 = GUICtrlCreateRadio(".mp3", 16, 88, 49, 17) $Radio2 = GUICtrlCreateRadio(".mp4", 16, 112, 49, 17) $Radio3 = GUICtrlCreateRadio(".jpg", 16, 136, 41, 17) $Group1 = GUICtrlCreateGroup("Extension", 8, 72, 65, 105) GUICtrlCreateGroup("", -99, -99, 1, 1) $Radio4 = GUICtrlCreateRadio("Save Extension", 96, 104, 113, 17) $Radio5 = GUICtrlCreateRadio("Delete Extension", 96, 128, 113, 17) $Group2 = GUICtrlCreateGroup("Options", 72, 72, 145, 105) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel("Setup", 40, 8, 74, 36) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Path: ", 144, 40, 208, 33) $Button2 = GUICtrlCreateButton("Start Clean", 256, 96, 91, 65, 0) GUICtrlSetState($Button2, $gui_disable) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button1 $path = FileSelectFolder("Choose Folder to Clean", "") GUICtrlSetData($Label2, "Path: " & $path) GUICtrlSetState($Button2, $gui_enable) Case $nMsg = $Button2 $mp3 = GUICtrlRead($Radio1); 1 is selected $mp4 = GUICtrlRead($Radio2) $jpg = GUICtrlRead($Radio3) $save = GUICtrlRead($Radio4) $delete = GUICtrlRead($Radio5) GUIDelete() ExitLoop EndSelect WEnd _ext () Func _ext () Select Case $mp3 = 1 $ext = ".mp3" Case $mp4 = 1 $ext = ".mp4" Case $jpg = 1 $ext = ".jpg" Case Else MsgBox(0, "Error", "No extension selected.") Exit EndSelect Select Case $save = 1 $var = 1 Case $delete = 1 $var = 2 Case Else MsgBox(0, "Error", "Error") EndSelect Endfunc _Search () Func _Search () $search = FileFindFirstFile($path & "\*.*") If $search <> -1 Then $handle_Splash = SplashTextOn("", "Cleaning ...", "600", "50", "-1", "-1", 32+3, "", "", "") ; Delete Extension If $var = 2 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) = $ext Then FileDelete($path & '\' & $file) While FileExists ($file) sleep (1) WEnd ControlSetText($handle_Splash, "", "Static1", "Cleaning... " & $file) EndIf WEnd EndIf ; Save Extension If $var = 1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) <> $ext Then FileDelete($path & '\' & $file) While FileExists ($file) sleep (1) WEnd ControlSetText($handle_Splash, "", "Static1", "Cleaning... " & $file) EndIf WEnd EndIf FileClose($search) SplashOff() Else MsgBox(0x30, @ScriptName, 'Search Failed Completely.') EndIf EndFunc Func _exit() If $search And $search <> -1 Then FileClose($search) EndIf Exit EndFunc;==>_exit Thx to Geosoft and Mhz for helping me with the script. ^ This guy pretty much wrote the script Edited July 25, 2007 by sccrstvn93 Link to comment Share on other sites More sharing options...
James Posted July 23, 2007 Share Posted July 23, 2007 Nice you should look at adding more filetypes! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
qazwsx Posted July 24, 2007 Author Share Posted July 24, 2007 Updated Link to comment Share on other sites More sharing options...
James Posted July 24, 2007 Share Posted July 24, 2007 Hey, Change $Form1 = GUICreate("Clean", 375, 186, 193, 123)oÝ÷ ÚÚºÚ"µÍÌÍÑÜLHHÕRPÜX]J ][ÝÐÛX[][ÝËÍÍKN LKLJoÝ÷ ص©Þ®º+§¶¼¢hrW«¢+ÙèÀäÈíAɽɵµ¥¹ÀäÈíµÀ̹ÔÌ ÜȤèôôÐìYÉ¥±ÕÍݥѡ½ÕÐ¥¹±É¸è)%ÀÌØíÙÈôÈQ¡¸)%xII= Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
GEOSoft Posted July 24, 2007 Share Posted July 24, 2007 Hey, Change $Form1 = GUICreate("Clean", 375, 186, 193, 123)oÝ÷ ÚÚºÚ"µÍÌÍÑÜLHHÕRPÜX]J ][ÝÐÛX[][ÝËÍÍKN LKLJoÝ÷ ص©Þ®º+§¶¼¢hrW«¢+ÙèÀäÈíAɽɵµ¥¹ÀäÈíµÀ̹ÔÌ ÜȤèôôÐìYÉ¥±ÕÍݥѡ½ÕÐ¥¹±É¸è)%ÀÌØíÙÈôÈQ¡¸)%xII=I just bet you did. For some reason the conditions for creating $Var were not met. Probably because Select Case $save = 1 $var = 1 Case $delete = 1 $var = 2 Case Else MsgBox(0, "Error", "Error") EndSelect Is Outside the Msg Loop Either place it in a function and declare $Var globaly or put it in the loop I think that the same will apply to a lot of the script George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
qazwsx Posted July 24, 2007 Author Share Posted July 24, 2007 alright i think i fixed it, but im sure if i totally get what your saying. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 24, 2007 Share Posted July 24, 2007 (edited) This small program cleans out your music folder. It deletes all files that are not .mp3. I use this to get rid of the album art that often comes with songs. This shrunk my music folder from 9 gigs to 4.5 and left all of my songs intact. WARNING IF YOU USE ITUNE YOUR SONGS MAY BE .MP4 You can stop this program at any time by pressing escape. Simply copy the script into your music folder and run it. It will delete itself when finished. It now support .mp3, mp4, and jpg, and has the option to save that extension or delete it. expandcollapse popup;music indexer HotKeySet("{esc}", "_exit") Global $var Global $search Global $ext Global $path Global $file Global $efile #include <GUIConstants.au3> $Form1 = GUICreate("Clean", 375, 186, -1, -1) $Button1 = GUICtrlCreateButton("Select Folder", 144, 8, 91, 33, 0) $Radio1 = GUICtrlCreateRadio(".mp3", 16, 88, 49, 17) $Radio2 = GUICtrlCreateRadio(".mp4", 16, 112, 49, 17) $Radio3 = GUICtrlCreateRadio(".jpg", 16, 136, 41, 17) $Group1 = GUICtrlCreateGroup("Extension", 8, 72, 65, 105) GUICtrlCreateGroup("", -99, -99, 1, 1) $Radio4 = GUICtrlCreateRadio("Save Extension", 96, 104, 113, 17) $Radio5 = GUICtrlCreateRadio("Delete Extension", 96, 128, 113, 17) $Group2 = GUICtrlCreateGroup("Options", 72, 72, 145, 105) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel("Setup", 40, 8, 74, 36) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Path: ", 144, 40, 208, 33) $Button2 = GUICtrlCreateButton("Start Clean", 256, 96, 91, 65, 0) GUICtrlSetState($Button2, $gui_disable) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button1 $path = FileSelectFolder("Choose Folder to Clean", "") GUICtrlSetData($Label2, "Path: " & $path) GUICtrlSetState($Button2, $gui_enable) Case $nMsg = $Button2 $mp3 = GUICtrlRead($Radio1); 1 is selected $mp4 = GUICtrlRead($Radio2) $jpg = GUICtrlRead($Radio3) $save = GUICtrlRead($Radio4) $delete = GUICtrlRead($Radio5) GUIDelete() ExitLoop EndSelect WEnd _ext () Func _ext () Select Case $mp3 = 1 $ext = ".mp3" Case $mp4 = 1 $ext = ".mp4" Case $jpg = 1 $ext = ".jpg" Case Else MsgBox(0, "Error", "No extension selected.") Exit EndSelect Select Case $save = 1 $var = 1 Case $delete = 1 $var = 2 Case Else MsgBox(0, "Error", "Error") EndSelect Endfunc _Search () Func _Search () $search = FileFindFirstFile($path & "\*.*") If $search <> -1 Then $handle_Splash = SplashTextOn("", "Cleaning ...", "600", "50", "-1", "-1", 32+3, "", "", "") ; Delete Extension If $var = 2 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) = $ext Then FileDelete($path & '\' & $file) While FileExists ($file) sleep (1) WEnd ControlSetText($handle_Splash, "", "Static1", "Cleaning... " & $file) EndIf WEnd EndIf ; Save Extension If $var = 1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) <> $ext Then FileDelete($path & '\' & $file) While FileExists ($file) sleep (1) WEnd ControlSetText($handle_Splash, "", "Static1", "Cleaning... " & $file) EndIf WEnd EndIf FileClose($search) SplashOff() Else MsgBox(0x30, @ScriptName, 'Search Failed Completely.') EndIf EndFunc Func _exit() If $search And $search <> -1 Then FileClose($search) EndIf Exit EndFunc;==>_exit Thx to Geosoft and Mhz for helping me with the script.Try using this for your Search func Func Search($Var, $Ext) If $Var <> 1 And $Var <> 2 Then Return SetError(1);; $Var is out of range ; Save Extension Switch $Var Case 1 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) <> $ext Then FileDelete($path & '\' & $file) While FileExists ($file) sleep (1) WEnd ControlSetText($handle_Splash, "", "Static1", "Cleaning... " & $file) EndIf WEnd Case 2 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) = $ext Then FileDelete($path & '\' & $file) While FileExists ($file) sleep (1) WEnd ControlSetText($handle_Splash, "", "Static1", "Cleaning... " & $file) EndIf WEnd Case Else MsgBox(0x30, @ScriptName, 'Search Failed Completely.') EndSwitch EndFunc ;<==> _DelFiles($Var, $Ext) WARNING:: NOT tested Edit:: Also in your MsgLoop Case $nMsg = $Button2 $mp3 = GUICtrlRead($Radio1); 1 is selected $mp4 = GUICtrlRead($Radio2) $jpg = GUICtrlRead($Radio3) $save = GUICtrlRead($Radio4) $delete = GUICtrlRead($Radio5) Select Case $mp3 = 1 $ext = ".mp3" Case $mp4 = 1 $ext = ".mp4" Case $jpg = 1 $ext = ".jpg" Case Else MsgBox(0, "Error", "No extension selected.") Exit EndSelect GUIDelete() ExitLoop Edited July 24, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 24, 2007 Share Posted July 24, 2007 Better yet Case $nMsg = $Button2 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 24, 2007 Share Posted July 24, 2007 (edited) Better Yet Case $nMsg = $Button2 $Ext = '' If GUICtrlRead($Radio1) = 1 Then $Ext = ".mp3" If GUICtrlRead($Radio2) = 1 Then $Ext = ".mp4" If GUICtrlRead($Radio3) = 1 Then $Ext = ".jpg" $save = GUICtrlRead($Radio4) $delete = GUICtrlRead($Radio5) GUIDelete() ExitLoop Then you don't need the _Ext() function at all Add If $Ext = "" Then MsgBox(0, "Error", "No extension selected.") Exit EndIf At the beginning of the Search function This way you only have to call the one function after your MsgLoop is closed EDIT:: BTW: Am I missing something here or do you have 2 unused Ctrls in there ($Radio1 and $Radio2)? If so what is (or was) their intended functions? Also is there a reason why you want to close the GUI at that point? This script could perhaps be made more functional with these answers. Edited July 24, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
qazwsx Posted July 25, 2007 Author Share Posted July 25, 2007 $radio 1 and 2 are mp3 and mp4 extensions. Yeh i think im goin to keep the gui open and use that instead of splashtext. So is it better to right my script as a series of functions? Thx for all the help Geosoft. Edit: while trying to fix the script i think i totally screwed it up. Im gonna take a break from it and try later Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Share Posted July 25, 2007 (edited) $radio 1 and 2 are mp3 and mp4 extensions. Yeh i think im goin to keep the gui open and use that instead of splashtext. So is it better to right my script as a series of functions? Thx for all the help Geosoft.Edit: while trying to fix the script i think i totally screwed it up. Im gonna take a break from it and try laterProbably but I'll take another look at it in the morning and see what I can come up with.Sorry I think I meant $Radio4 & $Radio5. I don't see where they are used but it might just be me.If you are going to keep the GUI open then have a look at either a progress bar or possible the GUIStatusBar UDF. I really think that the script will run too fast for either to be of value though, Unless you wrote the found files into an array before delete and that will slow you down a bit.The best way to show that it's still busy will beGUISetCursor(15, 1)And Then GUISetCursor(-1) on completion. That would be the right point to close the GUI. The benefit of leaving it open is the possibility that the user might want to delete more than 1 file type. That could still be done all in 1 operation by changing $Radio 1 through 3 with checkBoxes. Edited July 25, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
qazwsx Posted July 25, 2007 Author Share Posted July 25, 2007 yeh thats a good idea with the gui. The $radio 4 and 5 are to determine is the script should save the file type or delete it. Link to comment Share on other sites More sharing options...
James Posted July 25, 2007 Share Posted July 25, 2007 You really need to to name the $Radio1 etc with proper names. This makes much more sense. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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