-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsize.ImageTool.ps1
72 lines (59 loc) · 2.48 KB
/
size.ImageTool.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Description: This script resizes images in the central folder.
$todaysDate = Get-Date -Format "dd/MM/yyyy.HH:mm:ss"
# Config File Import
. "$PSScriptRoot\config.ps1"
if ($useHeader -eq "1") {
. "$PSScriptRoot\header.ps1"
}
# Script Timer
$elapsedTime = Measure-Command {
# Check if the script should run
if ($scriptLock) {
Write-Host "Scripts are locked. Please check readme.md for more information."
return
}
# Import Variables
$updatedLines = @() # This is for writing to salonOutcome
# Create new log file
Write-Host "Log>" $logFilePull
New-Item $logFilePull -type file
# Retrieve salon information from the CSV file
$header = Get-Content -Path $computerListFile -TotalCount 1
$notHeader = Get-Content $computerListFile | Select-Object -Skip 1
$notHeader | ForEach-Object {
# Set salon variables
$parts = $_ -split ',' # Split id and name (comma separated)
$salonId = $parts[0].Trim()
$salonName = $parts[1].Trim()
$pullOutcome = $parts[2].Trim()
$pushOutcome = $parts[3].Trim()
$salonLocked = $parts[4].Trim() # This is changed on every loop depending on prior operation
# Config File Import Again
. "$PSScriptRoot\config.ps1"
if ($salonLocked -eq "1") {
Write-Host "Salon is locked. Please check readme.md for more information."
$outcome = 1
$updatedLine = "$salonId,$salonName,$outcome,$salonLocked"
$updatedLines += $updatedLine
return
}
$0x00B4 = [char]0x00B4
$spinnerArray
$spinnerIndex = 0
Write-Host ""
# Resizer
Get-ChildItem -Path $destination -Filter *.jpg | ForEach-Object {
$fileSizeKB = (Get-Item $_.FullName).Length / 1KB
$lastAccessed = (Get-Item $_.FullName).LastAccessTime
#if ($fileSizeKB -gt $minSizeKB -and ($currentDate - $lastAccessed).TotalDays -lt 5) {
if ($fileSizeKB -gt $minSizeKB) {
& "$PSScriptRoot\ffmpeg.exe" -loglevel error -y -i $_.FullName -vf "scale=$resolution" $_.FullName
}
$spinner = $spinnerArray[$spinnerIndex++ % $spinnerArray.Length]
Write-Host -NoNewline "`r $spinner"
}
Write-Host $salonName ":" -NoNewLine
Write-Host "Image processing complete."
}
}
Write-Host "Size:Total elapsed time: $($elapsedTime.TotalMilliseconds) Milliseconds or $($elapsedTime.TotalMinutes) Minutes"