New
#21
Contig.exe is a pre-req. Download it from https://docs.microsoft.com/en-us/sys...wnloads/contig
I'll add a check for that.
I downloaded Contig, ran your script, and got the following:
Why not add the following line to download it?
Code:IWR -URI 'https://download.sysinternals.com/files/Contig.zip' -OutFile "E:\Testing\Contig.zip"
Then useExpand-Archive
to extract the files.
Do you intend to useOptimize-Volume
? If not, what will you use?
@Matthew Wai I added a check for Contig.exe on the path and the current folder. Yes, code could be added to download Contig.exe, but then you could argue that the code should also check if the machine is 64bit and run that version if it is. The enhancements may never end. Anyhow, it's not my script. I was just helping @einstein1969 get started. It's up to him now to add further enhancements.
@einstein1969 I'm not sure there is any value in finding the "Allocated Size" values from the command "FSUtil File Layout". Here is the output from Contig and FSUtil for a large file that has 20 fragments:
Code:Contig "C:\Movies\Fragmented File Test.mkv" Contig v1.8 - Contig Copyright (C) 2001-2016 Mark Russinovich Sysinternals Summary: Number of files processed: 1 Number of files defragmented: 1 Number unsuccessfully procesed: 0 Average fragmentation before: 20 frags/file Average fragmentation after : 20 frags/fileMaybe you should be looking at the output of "FSUtil File QueryExtents"? This is what I got for the same test file:Code:fsutil file layout "C:\Movies\Fragmented File Test.mkv" ********* File 0x00c4000000013d76 ********* File reference number : 0x00c4000000013d76 File attributes : 0x00000020: Archive File entry flags : 0x00000000 Link (ParentID: Name) : 0x018c0000000018ed: DOS Name : FRAGME~1.MKV Link (ParentID: Name) : 0x018c0000000018ed: NTFS Name : \Movies\Fragmented File Test.mkv Creation Time : 3/7/2021 14:14:23 Last Access Time : 7/14/2021 14:22:07 Last Write Time : 5/18/2021 0:51:16 Change Time : 7/14/2021 14:22:07 LastUsn : 61,538,451,304 OwnerId : 0 SecurityId : 28921 StorageReserveId : 0 Stream : 0x010 ::$STANDARD_INFORMATION Attributes : 0x00000000: *NONE* Flags : 0x0000000c: Resident | No clusters allocated Size : 72 Allocated Size : 72 Stream : 0x030 ::$FILE_NAME Attributes : 0x00000000: *NONE* Flags : 0x0000000c: Resident | No clusters allocated Size : 90 Allocated Size : 96 Stream : 0x030 ::$FILE_NAME Attributes : 0x00000000: *NONE* Flags : 0x0000000c: Resident | No clusters allocated Size : 114 Allocated Size : 120 Stream : 0x080 ::$DATA Attributes : 0x00000000: *NONE* Flags : 0x00000010: Has Parsed Information Size : 5,868,919,362 (5.5 GB) Allocated Size : 5,868,920,832 (5.5 GB) Vdl : 5,868,919,362 (5.5 GB) Extents : 20 Extents
Code:fsutil file queryextents "C:\Movies\Fragmented File Test.mkv" VCN: 0x0 Clusters: 0x3f31 LCN: 0x6d559f VCN: 0x3f31 Clusters: 0x4f3d LCN: 0x15b8123 VCN: 0x8e6e Clusters: 0xbafc LCN: 0x146fd9c VCN: 0x1496a Clusters: 0xbd60 LCN: 0x18c2f78 VCN: 0x206ca Clusters: 0xc224 LCN: 0x12fcdd8 VCN: 0x2c8ee Clusters: 0xc27c LCN: 0x44b8e78 VCN: 0x38b6a Clusters: 0x157ac LCN: 0x28873c4 VCN: 0x4e316 Clusters: 0xc9c0 LCN: 0x30641e8 VCN: 0x5acd6 Clusters: 0xe004 LCN: 0x131ae54 VCN: 0x68cda Clusters: 0x16730 LCN: 0x16975b8 VCN: 0x7f40a Clusters: 0xe004 LCN: 0x17a6108 VCN: 0x8d40e Clusters: 0x16c1c LCN: 0x1af1b20 VCN: 0xa402a Clusters: 0x17088 LCN: 0x6c8ad54 VCN: 0xbb0b2 Clusters: 0x17788 LCN: 0x4b0fa20 VCN: 0xd283a Clusters: 0x177f0 LCN: 0x21a3be0 VCN: 0xea02a Clusters: 0x17bd8 LCN: 0x2a3d488 VCN: 0x101c02 Clusters: 0x19a74 LCN: 0x102a2a8 VCN: 0x11b676 Clusters: 0x19cfc LCN: 0x309a140 VCN: 0x135372 Clusters: 0x1ad9a LCN: 0x1cb8860 VCN: 0x15010c Clusters: 0xdbfe LCN: 0x30c2f58
Hi Matthew, thank you.
She'll meet again after a while. I got busy, but still worked a little bit for that logging problem. When I can continue.
- - - Updated - - -
I updated the ps1 script but I can't find the size of any file on disk C.
On the external drive it seems to work insteadCode:C:\users\All Users\Microsoft\EdgeUpdate\Log\MicrosoftEdgeUpdate.log | 22 | C:\users\All Users\Microsoft\Windows\DeviceMetadataCache\dmrc.idx | 4 | C:\users\All Users\Microsoft\Windows Security Health\Logs\SHS-07122021-170346-7-7f-19041.1.amd64fre.vb_release.191206-1406.etl | 5 | C:\users\All Users\Microsoft\Windows Security Health\Logs\SHS-07132021-184421-7-7f-19041.1.amd64fre.vb_release.191206-1406.etl | 4 | C:\users\All Users\USOShared\Logs\System\MoUsoCoreWorker.0349849c-dbcc-40bf-ad8a-651c04d70161.1.etl | 4 |
For language-dependent strings we can do without it:Code:N: \ bck \ backup_macrium \ Version 1809 base \ FABC4503751A17D2-00-00.mrimg | 4 | 48 128 80 11,651,563,520 (10.9 GB) 57,344
You actually need the size allocated only for the stream ::$DATA
it is the fourth value in the section ::$DATA
For some files it does not work in the log I find:
Code:M: \ Labyrinth - Where Everything Is Possible - Ita_Eng.mkv | 15 | File cannot be found
and it looks like the code page problem I told you.
For reproduce problem try:
- download Victoria 5.36 (Victoria536.zip)
- extract
- found Русский.lng file
- try to fragment:
- for / L% L in (1,1,8) do type Русский.lng >> Русский.lng
- - - Updated - - -
Sorry the error message is:
- - - Updated - - -Code:M:\Labyrinth - Dove Tutto ╚ Possibile - Ita_Eng.mkv | 15 | File cannot be found
@all
the 64bit has bug and don't work well, use 32bit version of contig. work well for 32 and 64 bit.
add note that contig64 is broken . Issue #57 . MicrosoftDocs/sysinternals . GitHub
- - - Updated - - -
perhaps version 1.7 ...
https://social.technet.microsoft.com...orum=miscutils
The script retrieved the sizes of the files on my drive C.
Code:C:\ProgramData\Malwarebytes\MB3Service\dbupdate.log | 7 | 72 96 1,638,400 (1.6 MB) C:\ProgramData\Malwarebytes\MB3Service\Global.sr | 13 | 72 88 20,140,032 (19.2 MB) C:\ProgramData\Malwarebytes\MB3Service\rules.mbdb | 94 | 72 88 88 21,979,136 (21.0 MB) C:\ProgramData\Malwarebytes\MB3Service\scan.mbdb | 11 | 72 88 88 1,748,992 (1.7 MB) C:\ProgramData\Malwarebytes\MB3Service\tids.mbdb | 5 | 72 88 88 253,952 (248.0 KB) C:\ProgramData\Malwarebytes\MB3Service\ARW\mbarwind.arw | 13 | 72 96 13,107,200 (12.5 MB) C:\ProgramData\Malwarebytes\MB3Service\lkg_db\Global.sr | 17 | 72 88 20,140,032 (19.2 MB) 56 C:\ProgramData\Malwarebytes\MB3Service\lkg_db\rules.mbdb | 8 | 72 88 88 21,979,136 (21.0 MB) C:\ProgramData\Malwarebytes\MB3Service\lkg_db\wprot2.mbdb | 11 | 72 88 96 19,456,000 (18.6 MB) C:\ProgramData\Malwarebytes\MB3Service\LOGS\MBAMSERVICE.LOG | 13 | 72 96 96 7,602,176 (7.3 MB)
I am running an English version of Windows 10 with no Chinese language pack.
Right-click on the Start button --> Windows PowerShell
Run the following command and see whether the size will be displayed.
The following is my example output:Code:Write-Host([math]::round((Get-Item "C:\users\All Users\Microsoft\EdgeUpdate\Log\MicrosoftEdgeUpdate.log").Length/1MB,2))MB
Code:PS C:\Users\Matthew_Wai> Write-Host([math]::round((Get-Item "C:\users\All Users\Microsoft\EdgeUpdate\Log\MicrosoftEdgeUpdate.log").Length/1MB,2))MB 5.29 MB
I acknowledge receipt of your PM.
Stack Overflow is a weird site. Previously, it banned me from asking questions there. Recently, it has sent me an email, saying that "Because of recent increases to your Super User reputation, you now have the ability to participate in review queues". It is ironic.
@LesFerch
I have tried utf-8+bom and utf-16LE but the problem remain
@Matthew Wai
Code:PS C:\Users\fposc> Write-Host([math]::round((Get-Item "C:\users\All Users\Microsoft\EdgeUpdate\Log\MicrosoftEdgeUpdate.log").Length/1MB,2))MB 4,05 MB PS C:\Users\fposc>
Ok, I have solved the problem with disk C: I misunderstood and thought it was running as admin. I had to do the VBS because Paul Black's first method I couldn't get it to work.
I also solved part of the coding problem the same way I did in batch. How do I change the code page in powershell?
Code:PS C:\Users\fposc\Downloads\powerdefragmentergui> powershell -f .\Edefrag.ps1 Ricerca di file frammentati... Analizza i file con minimo 4 frammenti... M:\Labyrinth - Dove Tutto ╚ Possibile - Ita_Eng.mkv | 15 | File cannot be found PS C:\Users\fposc\Downloads\powerdefragmentergui> chcp 1252 Tabella codici attiva: 1252 PS C:\Users\fposc\Downloads\powerdefragmentergui> powershell -f .\Edefrag.ps1 Ricerca di file frammentati... Analizza i file con minimo 4 frammenti... M:\Labyrinth - Dove Tutto È Possibile - Ita_Eng.mkv | 15 | 72 168 16 4.699.717.632 (4,4 GB) 32 (0,0 KB) PS C:\Users\fposc\Downloads\powerdefragmentergui>
Last edited by einstein1969; 15 Jul 2021 at 17:54.
@einstein1969 I finally got the code page problem fixed. I updated the code in my original message.