qazwsx Posted July 23, 2007 Share Posted July 23, 2007 Im going to use this script to clean up space on my comp. $path = @ScriptDir MsgBox (0, "", $path) $search = FileFindFirstFile ("*.*") While 1 $file = FileFindNextFile ($search) If @error Then ExitLoop MsgBox (0, "", $file) $efile = StringTrimLeft ($file, StringInStr ($file, ".", 0, -1)) MsgBox (0, "", $efile) MsgBox (0, "", $file) If Not $efile = "mp3" Then FileDelete ($path & "\" & $file) MsgBox (0, "", "delete") Endif WEnd FileClose ($search) But the files never delete because it never goes to the if not. Link to comment Share on other sites More sharing options...
xcal Posted July 23, 2007 Share Posted July 23, 2007 Start with FileDelete('c:\actual\path\file.ext') and work backwards from there, adding in the If etc. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
cyanidemonkey Posted July 23, 2007 Share Posted July 23, 2007 (edited) It looks like you are deleting non mp3 files.Have a look at this, it may help you out: http://www.autoitscript.com/forum/index.php?showtopic=49320Mind you it will remove all non mp3 file, but you might be able to use a bit of the code to do what you require.Try this for your delete bit of code:If StringRight(StringLower($file), 4) <> ".mp3" Then FileDelete ($file) EndIfIf you want to just move to recyce bin then use FileRecycle($file) instead of FileDelete ($file), that way you can check the recycle bin and restore the file if you wanna keep it. Edited July 23, 2007 by cyanidemonkey My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator Link to comment Share on other sites More sharing options...
MHz Posted July 23, 2007 Share Posted July 23, 2007 If you want to just move to recyce bin then use FileRecycle($file) instead of FileDelete ($file), that way you can check the recycle bin and restore the file if you wanna keep it.FileRecycle() does not work on Volumes as they have no recycle bin. I would suggest a Edit control of files found to inspect before deletion but the Edit control has a amount of characters limitation so hopefully will not exceed the limitation. Link to comment Share on other sites More sharing options...
Confuzzled Posted July 23, 2007 Share Posted July 23, 2007 Why write code for something that can be accomplished by using common Windows procedures?Search for "*.*" on the root directory of the volume you wish to clean up. Sort by file extension by clicking on the 'type' column. Click on the first non-MP3 file, hold down the shift key and go down to the last file that is not a MP3 file and click on that to select all files between. Press the delete key and OK - voila! Link to comment Share on other sites More sharing options...
cyanidemonkey Posted July 23, 2007 Share Posted July 23, 2007 Why write code for something that can be accomplished by using common Windows procedures?Search for "*.*" on the root directory of the volume you wish to clean up. Sort by file extension by clicking on the 'type' column. Click on the first non-MP3 file, hold down the shift key and go down to the last file that is not a MP3 file and click on that to select all files between. Press the delete key and OK - voila!Because sometimes your dealing with a shit load of files within a shit load of folders. I recently wrote a simluar script to sccrstvn93 to clean up 100gb+ of music files/folders. The method you suggest is of course the option to take if there is not alot of stuff to clean, but for large amounts of data why do it manually when you can write a script to do it for you? My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator Link to comment Share on other sites More sharing options...
mikehunt114 Posted July 23, 2007 Share Posted July 23, 2007 1 mb to be removed = 2 seconds to highlight and delete 100 gigs = 15 seconds (generous) to highlight/scroll down and delete Nonetheless, I myself, enjoy automating tasks, even if it isn't really worth the effort IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] 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