goupingping Posted February 9, 2007 Share Posted February 9, 2007 Hello, I am testing one application which will create a result data folder after running. How can I get the name of the lastest created folder in my Autoit script? Deep appreciate any help! Pingping Link to comment Share on other sites More sharing options...
/dev/null Posted February 9, 2007 Share Posted February 9, 2007 Hello,I am testing one application which will create a result data folder after running. How can I get the name of the lastest created folder in my Autoit script? Deep appreciate any help! Pingping_FileListToArray() with flags! Then FileGetTime(). Probably also _DateDiff().Maybe easier:Run() Command: "dir /b /AD /OD" and parse output.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
stigma Posted February 9, 2007 Share Posted February 9, 2007 Im trying to do the same, but for files. Would that be doable in the same way? -Stigma Link to comment Share on other sites More sharing options...
goupingping Posted February 9, 2007 Author Share Posted February 9, 2007 Thank you very much! I still have problems as: 1) My script is $val = RunWait(@COMSPEC & " /c Dir C:\", @SW_MAXIMIZE ) I got this error message: ==> Unable to execute the external program.: $val = RunWait(@COMSPEC & " /c Dir C:\", @SW_MAXIMIZE ) The directory name is invalid. 2) How can I parse the result after I run the Dos command successfully? Thank you! Pingping Link to comment Share on other sites More sharing options...
evilertoaster Posted February 9, 2007 Share Posted February 9, 2007 @1: looks kidna like your commanline interprater isnt there...what about just a standard thing like Run(@ComSpec & " /c " & 'ipconfig', "", @SW_MAXIMIZE) ? @2: could get it in a text file and do some data managing add a "> somefile.txt" after a dos command to rerout the output to a text file...or use StdoutRead... Link to comment Share on other sites More sharing options...
Shevilie Posted February 9, 2007 Share Posted February 9, 2007 RunWait(@COMSPEC & " /c dir /A:D /B /O:D """ & $dirtosearch & """ >> News.log", $dirtosearch ) Then there will be a file News.log where the folders are named i date... Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
/dev/null Posted February 9, 2007 Share Posted February 9, 2007 Here is something to start.... #include <Constants.au3> #include <Array.au3> $dir = "C:\" $foo = Run(@ComSpec & " /c dir /B /OD /AD " & $dir, @SystemDir, @SW_HIDE, $STDOUT_CHILD) $line = "" While 1 $line &= StdoutRead($foo) If @error Then ExitLoop Wend $lines = StringSplit(StringStripCR($line),@LF) _ArrayDisplay($lines,"Folders in " & $dir) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
MrCreatoR Posted February 10, 2007 Share Posted February 10, 2007 Here is example of _NewestDir() function (whitout using a cmd) : #include <File.au3> $Path = @ScriptDir & "\test" $GetNewestDir = _NewestDir($Path, 1) If $GetNewestDir = -1 Then MsgBox(48, "Error", "The path <" & $Path & "> was not found") ElseIf $GetNewestDir = -2 Then MsgBox(48, "Error", "There is no folders in path <" & $Path & ">") Else MsgBox(64, "Newest folder results", "The newst folder in path <" & $Path & "> is [" & $GetNewestDir & "]") EndIf ;Return -1 if given path is not exists, return -2 if there is no folders in the path, else return the name of latest folder in the path ;By default returned last Modified folder, see this flags: ;0 = Modified (default) ;1 = Created ;2 = Accessed Func _NewestDir($sPath, $Flag=0) If Not FileExists($sPath) Then Return -1 Local $dList = _FileListToArray($sPath, "*", 2) If IsArray($dList) Then Local $NewstDir = $dList[1], $GetNewstDirTime = 0 For $iArr = 1 To $dList[0] $GetDirTime = FileGetTime($sPath & "\" & $dList[$iArr], $Flag, 1) If $GetDirTime > $GetNewstDirTime Then $NewstDir = $dList[$iArr] $GetNewstDirTime = FileGetTime($sPath & "\" & $NewstDir, $Flag, 1) Next Return $NewstDir Else Return -2 EndIf EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
goupingping Posted February 12, 2007 Author Share Posted February 12, 2007 Great thanks to all of you! -Pingping 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