Raffav Posted May 16, 2012 Share Posted May 16, 2012 Hello, i am new on autoit script i want to make a script that get the size of a file(the name of it, will be a variable inputed by a parameter) in current running directory (where the script is located) than will check if the size is => ei: 1Gb will pop up msgbox ie: scritp.ext namefile "another parameter" Thanks sorry for bad engish Link to comment Share on other sites More sharing options...
BrewManNH Posted May 16, 2012 Share Posted May 16, 2012 Look in the help file for the commands: _FileListToArray FileGetSize MsgBox 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...
Moderators Melba23 Posted May 16, 2012 Moderators Share Posted May 16, 2012 Raffav, Welcome to the AutoIt forum. What you want to do is very easy - take a look at the following in the Help file and you should be able to put something together: @ScriptDir - Where the script is located _FileListToArray - Get a list of the files in a folder For..Next - Loop through those files FileGetSize - Get the size of each file If...EndIf - Check if the file is > 1Gb MsgBox - Show the result. Give it a go and see how you get on - you know where we are if you run into difficulties. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Raffav Posted May 16, 2012 Author Share Posted May 16, 2012 Thanks, i will post son with some result or no Link to comment Share on other sites More sharing options...
searchresult Posted May 16, 2012 Share Posted May 16, 2012 Here to start with #include <File.au3> #include <Array.au3> $dirPath = "C:UsersMarkoDesktoptest" $fileArray = _FileListToArray($dirPath) $fileSize = 0 $size = 0 $fileName = "" For $i = 1 to UBound($fileArray) - 1 $fileSize = FileGetSize($fileArray[$i]) If $fileSize > $size Then $size = $fileSize $fileName = $fileArray[$i] EndIf Next MsgBox(0, "Largest file", "Largest file is " & $fileName) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 16, 2012 Moderators Share Posted May 16, 2012 searchresult,I see the "give a man a fish" versus "give a man a net" argument is lost on you. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Raffav Posted May 16, 2012 Author Share Posted May 16, 2012 here what i get and is almost what i want it is for control the size of the Outlook pst now i what to when the pst get >= 10GB it pop a gui with the msg saying some text but the windows must have minimize mazimize and X desable so user cant ignore it, need to click ON Exit buttons If $CMDLINE[0] = 0 Then ; parameter needed MsgBox(0,"", "parametro necessario") Exit EndIf ;~ Else Local $size = FileGetSize($CMDLINE[1]) if $size = 0 Then ; file not found/insert MsgBox(0,"","arquivo não encontrado/informado") ElseIf $size >= "945804" Then ; new pst needed MsgBox(0,"","nova pst necessaria "&$size) ElseIf $size >= "438412" Then ; pst near to limit MsgBox(0,"","Pst chegando no limite "&$size) ElseIf $size >= "356087" Then ; pst OK MsgBox(0,"","PST OK "&$size) EndIf Link to comment Share on other sites More sharing options...
BrewManNH Posted May 16, 2012 Share Posted May 16, 2012 Look at the GUICreate style of $WS_POPUP 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...
Raffav Posted May 17, 2012 Author Share Posted May 17, 2012 Thanks, I will give a look on it. And later I will ask to change the title name, is no more what I am looking for. Later with new info/question. Link to comment Share on other sites More sharing options...
Spiff59 Posted May 17, 2012 Share Posted May 17, 2012 (edited) Another, likely very fast, way to peg which file is largest in a directory: #include <Constants.au3> Global $sDirectory = @WindowsDir, $sStdOut $PID = Run(@ComSpec & ' /c DIR "' & $sDirectory & '" /B /A-D /O-S', "", @SW_HIDE, $STDOUT_CHILD) While Not @error $sStdOut &= StdoutRead($PID) WEnd $sStdOut = StringLeft($sStdOut, StringInStr($sStdOut, @CRLF) - 1) MsgBox(0, $sDirectory, "Largest file: " & $sStdOut) Edit: Change the "$sStdOut = " statemnet near the end to a StringSplit() and you'd have an array sorted by filesize. You could parse that and only have to call FileGetSize() for those files that meet the minimum filesize requirement (with the exception of the one FileGetSize() call that read the first file below the minimum size, causing an exit from the loop). Edit2: I suppose avoiding any FileGetSize() calls would be better: #include <Array.au3> ; for testing #include <Constants.au3> Global $sDirectory = @WindowsDir, $iMinSize = 500000, $sStdOut, $iIndex = 0 $PID = Run(@ComSpec & ' /c DIR "' & $sDirectory & '" /A-D /-C /O-S', "", @SW_HIDE, $STDOUT_CHILD) While Not @error $sStdOut &= StdoutRead($PID) WEnd $aStdOut = StringSplit($sStdOut, @CRLF) For $x = 1 To $aStdOut[0] ; pack and (partially) format array If StringMid($aStdOut[$x], 3, 1) = "/" Then $aStdOut[$x] = StringStripWS($aStdOut[$x], 7) $aStdOut[$x] = StringTrimLeft($aStdOut[$x], StringInStr($aStdOut[$x], " ", 2, 3)) If $aStdOut[$x] < $iMinSize Then ExitLoop $iIndex += 1 $aStdOut[$iIndex] = $aStdOut[$x] EndIf Next $aStdOut[0] = $iIndex ReDim $aStdOut[$iIndex + 1] _ArrayDisplay($aStdOut, "Files > " & $iMinSize) ; for testing I am guilty sometimes of providing the net, but I've left holes in this, and the OP has posted original code showing he's making the effort Edited May 17, 2012 by Spiff59 Link to comment Share on other sites More sharing options...
Raffav Posted May 17, 2012 Author Share Posted May 17, 2012 Look at the GUICreate style of $WS_POPUPsorry but i cant find any reference for $ws_popup in help file Link to comment Share on other sites More sharing options...
BrewManNH Posted May 17, 2012 Share Posted May 17, 2012 Read the entire sentence. Step 1 - Read the help file for information about GUICreate Step 2 - Look at the styles for GUICreate and find $WS_POPUP, there's a hyperlink in the help file under GUICreate for the styles and extended styles for the function. 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...
Raffav Posted May 17, 2012 Author Share Posted May 17, 2012 Read the entire sentence.Step 1 - Read the help file for information about GUICreateStep 2 - Look at the styles for GUICreate and find $WS_POPUP, there's a hyperlink in the help file under GUICreate for the styles and extended styles for the function.Yes i already fount it, but i dont know/have success to make the pop up with right conner windows "_ |_| X desable " Link to comment Share on other sites More sharing options...
BrewManNH Posted May 17, 2012 Share Posted May 17, 2012 The ws_popup style doesn't have those controls on the GUI, so there's no need to disable them. If for some reason you want those controls on the GUI but they are disabled then you're going to have to search for the numerous examples in the forum for that as I can't recall how it's done. 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...
Raffav Posted May 17, 2012 Author Share Posted May 17, 2012 (edited) it will be something like that? #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### $Form1 = GUICreate("pst alert", 431, 156,$WS_POPUP) $Edit1 = GUICtrlCreateEdit("", 8, 16, 409, 97) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Button1", 24, 120, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 144, 120, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ###e EDIT1 i down know the name but in the autoitscript Editor has a hot key that organize the scirpt like ie: if something then some string else another string endfi Edited May 18, 2012 by Raffav Link to comment Share on other sites More sharing options...
Raffav Posted May 18, 2012 Author Share Posted May 18, 2012 How i said i am a very noob in autoit (traying to find answer in the forum/google) Yes is a mess i want when a if is (True) meet it show up a gui box with a edit box (readonly) with only one if i have maked work but i put elseif or else i cant make work expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### $Form1 = GUICreate("pst alert", 431, 156) $Edit1 = GUICtrlCreateEdit("", 8, 16, 409, 97,$WS_VSCROLL) ;GUICtrlSetData(-1,"teste") $Button1 = GUICtrlCreateButton("Button1", 24, 120, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 144, 120, 75, 25) ;GUISetState(@SW_SHOW) _GUICtrlEdit_SetReadOnly($Edit1, True) #EndRegion ### END Koda GUI section ### If $CMDLINE[0] = 0 Then ; paramet needed ;MsgBox(0,"", "parametro necessario") GUISetState(@SW_SHOW) GUICtrlSetData($Edit1, "Parametro Necessário") ;Exit ;Else ;~ While 1 ;~ $nMsg = GuiGetmsg() ;~ Switch $nMsg ;~ Case $GUI_EVENT_CLOSE ;~ Exit ;~ case $Button1 ;~ Exit ;~ case $Button2 ;~ Exit ;~ EndSwitch ;~ WEnd Local $size = FileGetSize($CMDLINE[1]) if $size = 0 Then ; file not found/insert ;~ MsgBox(0,"","arquivo não encontrado/informado") GUISetState(@SW_SHOW) GUICtrlSetData($Edit1, "Parametro Necessário22") ElseIf $size >= "945804" Then ; new pst needed ;MsgBox(0,"","nova pst necessaria "&$size) GUISetState(@SW_SHOW) ElseIf $size >= "438412" Then ; pst near to limit ;MsgBox(0,"","Pst chegando no limite "&$size) GUISetState(@SW_SHOW) ElseIf $size >= "356087" Then ; pst OK ;MsgBox(0,"","PST OK "&$size) GUISetState(@SW_SHOW) While 1 $nMsg = GuiGetmsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;~ case $Button1 ;~ Exit ;~ case $Button2 ;~ Exit EndSwitch WEnd EndIf EndIf Link to comment Share on other sites More sharing options...
Raffav Posted June 4, 2012 Author Share Posted June 4, 2012 Hello i again and if i want to get the smallest file ? that have extension ".PST" i try to figured out using this one but i cant understand how it work so i cant change to smallest #include <File.au3> #include <Array.au3> $dirPath = "C:UsersMarkoDesktoptest" $fileArray = _FileListToArray($dirPath) $fileSize = 0 $size = 0 $fileName = "" For $i = 1 to UBound($fileArray) - 1 $fileSize = FileGetSize($fileArray[$i]) If $fileSize > $size Then $size = $fileSize $fileName = $fileArray[$i] EndIf Next MsgBox(0, "Largest file", "Largest file is " & $fileName) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 4, 2012 Moderators Share Posted June 4, 2012 Raffav,Look at the _FileListToArray command in the Help file to see how to limit the returns to only "*.pst" files. As to the smallest file - you need something like this:$fileName = "" $size = 1e10 ; Set a big number to start with For $i = 1 to UBound($fileArray) - 1 $fileSize = FileGetSize($fileArray[$i]) If $fileSize < $size Then ; Now see if this file is even smaller $size = $fileSize $fileName = $fileArray[$i] EndIf Next MsgBox(0, "Smallest file", "Smallest file is " & $fileName)All clear? M23 Raffav 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Raffav Posted June 4, 2012 Author Share Posted June 4, 2012 Raffav, Look at the _FileListToArray command in the Help file to see how to limit the returns to only "*.pst" files. As to the smallest file - you need something like this: $fileName = "" $size = 1e10 ; Set a big number to start with For $i = 1 to UBound($fileArray) - 1 $fileSize = FileGetSize($fileArray[$i]) If $fileSize < $size Then ; Now see if this file is even smaller $size = $fileSize $fileName = $fileArray[$i] EndIf Next MsgBox(0, "Smallest file", "Smallest file is " & $fileName) All clear? M23 thanks alot i was getting close to your solution kkkk and i already find the way to filter for *.pst the help file is a GOD help kkk Link to comment Share on other sites More sharing options...
Raffav Posted June 11, 2012 Author Share Posted June 11, 2012 Hello again i think the way is using arrays but i cant find how to how to get the 2,ou 3, N smalest file, with the size corresponding to the file name Thanks Again sorry for Bad english Raffav 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