-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.ps1
29 lines (27 loc) · 841 Bytes
/
sync.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$Path = "."
# display progress bar
function writeProgress {
param (
[int]$i,
[int]$fileCount,
[string]$fileName,
[decimal]$duration
)
$progress = [math]::Round($i/$fileCount * 100, 0)
Write-Progress `
-Activity "fetching files" `
-Status "(${i}/${fileCount}) (${duration}sec) $fileName" `
-PercentComplete $progress
}
cls
$fileCount = Get-ChildItem $Path -Recurse | Measure-Object
$files = Get-ChildItem $Path -Recurse | Sort-Object -Descending CreationTime
$i = 0
foreach ($f in $files){
$i++
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
Get-Content -Path $f.FullName | out-null
$stopwatch.Stop()
$totalSecs = "{0:n1}" -f [math]::Round($stopwatch.Elapsed.TotalSeconds, 1)
writeProgress $i $fileCount.Count $f.FullName $totalSecs
}