copyleft Posted August 20, 2006 Share Posted August 20, 2006 Can anybody convert this visual basic script to autoit. (It basically deletes files older than 10 days from the indicated directory). Shortening the routine would also be greatly appreciated. expandcollapse popup'work in this folder path = "G:\Image" 'delete files/folders older than 10 days killdate = date() - 10 set fso = createobject("scripting.filesystemobject") arFiles = array() count = -1 SelectFiles path, killdate dcount = 0 for each file in arFiles s = s & file.name & vbcrlf on error resume next file.delete true if err.number = 0 then dcount = dcount + 1 err.clear on error goto 0 next DeleteEmptyFolders path,false 'msgbox count+1 & " files found, " & dcount & " deleted." sub SelectFiles(sPath, vKillDate) set folder = fso.getfolder(sPath) set files = folder.files for each file in files dtlastmodified = null on error resume Next dtlastmodified = file.datelastmodified on error goto 0 if not isnull(dtlastmodified) Then if dtlastmodified < vKillDate then count = count + 1 redim preserve arFiles(count) set arFiles(count) = file end if end if next for each fldr in folder.subfolders SelectFiles fldr.path, vKillDate next end sub sub DeleteEmptyFolders(sPath,bDeleteThisFolder) set folder = fso.getfolder(sPath) for each fldr in folder.subfolders DeleteEmptyFolders fldr.path,true next if (folder.files.count = 0) and _ (folder.subfolders.count) = 0 and _ bDeleteThisFolder then folder.delete exit sub end if end sub Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 20, 2006 Share Posted August 20, 2006 Older than 10 days? By that I assume you mean creation date? Link to comment Share on other sites More sharing options...
randallc Posted August 20, 2006 Share Posted August 20, 2006 (edited) HiTyr the linked file;Deleting old filesor modify JDEB's findfiles; JDEB stuffor use other files in "recursive" link in my sigBest, randall Edited August 20, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
DaleHohm Posted August 20, 2006 Share Posted August 20, 2006 To get you started:Change set fso = createobject("scripting.filesystemobject") to $fso = ObjCreate("scripting.filesystemobject")start all of your variables with a '$' and don't use 'set'the rest of the syntax will be pretty similarGive it a try, post your results and specific questions.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 20, 2006 Share Posted August 20, 2006 Also look for a VBScript to AutoIt Converter. There is one in the Scripts and Scraps section. I never seem to have the link handy either. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
vim Posted August 20, 2006 Share Posted August 20, 2006 Also look for a VBScript to AutoIt Converter. There is one in the Scripts and Scraps section. I never seem to have the link handy either.JSHere it is:http://www.autoitscript.com/forum/index.ph...ost&p=83650 Link to comment Share on other sites More sharing options...
copyleft Posted August 21, 2006 Author Share Posted August 21, 2006 (edited) I tried the VBS converter. Didn't work for me. Will try the other suggestions. Thanks all. Edited August 21, 2006 by copyleft 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