Exit Posted May 18, 2020 Share Posted May 18, 2020 I would like to see how many fragments a file is fragmented into. Unfortunately I didn't find any clues in the forum. Can someone give me the crucial clue? App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
argumentum Posted May 18, 2020 Share Posted May 18, 2020 (edited) ..but that has to do with the file system. As far as AutoIt knows, it requests a "file" and the OS reads it to it. Edit: more over. If is an SSD or an iSCSI or HDD or .... . You can not defragment the file even if read and rewritten, as the file system is the one that handles that. Edited May 18, 2020 by argumentum expand Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Exit Posted May 18, 2020 Author Share Posted May 18, 2020 Just a code snipped to show what i want: Local $File = "C:\Windows\System32\Tasks\Microsoft\Windows\Defrag\ScheduledDefrag" MsgBox(64+262144, Default, "the Fragmentscount of "&$File& " is "&_GetFragmentsCount($File),0) Func _GetFragmentsCount($File) Local $Fragmentscount=0 ;~ please insert the magic code here Return $Fragmentscount EndFunc argumentum 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
seadoggie01 Posted May 18, 2020 Share Posted May 18, 2020 I think you can use Contig from M$ with the a and v command line options. You'll need to parse the output, of course. https://docs.microsoft.com/en-us/sysinternals/downloads/contig (Link to documentation, not direct download) Exit 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Exit Posted May 26, 2020 Author Share Posted May 26, 2020 Thanks to @seadoggie01 Based on his advice, I could build a solution: #include <String.au3> $File = "C:\Windows\System32\LogFiles\WMI\Wifi.etl" $Pgm = @MyDocumentsDir & "\Data\Software\SysinternalsSuite\Contig.exe" If Not FileExists($Pgm) Then MsgBox(16 + 262144, Default, "File " & $Pgm & " not found." & @LF & @LF & "Install it from here: https://live.sysinternals.com/Contig.exe", 0) MsgBox(64 + 262144, Default, "The fragmentscount of " & @LF & @LF & $File & @LF & @LF & "is " & _GetFragmentsCount($File), 0) Func _GetFragmentsCount($File) If Not FileExists($File) Then Return MsgBox(64+262144, Default, "File not found:"&@lf&@lf&$File,9)*0 + SetError(1, 0, 0) $iPID = Run(@ComSpec & " /c " & $Pgm & " -a -nobanner " & $File, "", default, 8) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) $aFound = _StringBetween($sOutput, "in ", " Fragments") If @error Then Return SetError(0, 0, 1) Return $aFound[0] EndFunc ;==>_GetFragmentsCount App: Au3toCmd UDF: _SingleScript() 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