-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNGToolKit.ps1
185 lines (159 loc) · 6.2 KB
/
DNGToolKit.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
[CmdletBinding()]
param ()
# Import function library
. "$PSScriptRoot\Library.ps1"
# Import settings from config file
[xml]$ConfigFile = Get-Content "Settings.xml"
$src_volume_import = $ConfigFile.settings.folders.sdcard
$src_extension = $ConfigFile.settings.environment.extension
$convert_root_path = $ConfigFile.settings.folders.convertation
$workplace_root_path = $ConfigFile.settings.folders.workplace
$dng_exec_path = $ConfigFile.settings.dng.path
$dng_exec_bin = $ConfigFile.settings.dng.binary
$dng_base_args = $ConfigFile.settings.dng.arguments
$WhatIfPreference = $false # $ConfigFile.settings.other.testing
$disclaimer = $ConfigFile.settings.other.disclaimer
<#
.SYNOPSIS
Automatic conversion of multiple RAW files to DNG format with Adobe DNG Converter via PowerShell
.DESCRIPTION
This PowerShell script supports Lightroom 6.14 on-premise users. Several actions are available.
For more information please refer to the README.MD
.EXAMPLE
./DNGToolKit.bat
.NOTES
Author: Benedikt Filip
License: DNG ToolKit and all individual scripts are under the BSD 3-Clause license
.LINK
https:/www.filipnet.de
#>
# Check on start
Clear-Host
Write-Host -BackgroundColor Blue "Check system environments on startup"
Write-Host ""
Write-Host -NoNewline "Check Whatif: "
if ($WhatIfPreference)
{
Write-Host -ForegroundColor Green "ENABLED "
}else{
Write-Host -ForegroundColor Yellow "DISABLED "
}
Write-Host -NoNewline "Check PowerShell Version: "
if ($PSVersionTable.PSVersion.Major -gt 3)
{
Write-Host -ForegroundColor Green "PASSED "
}else{
Write-Host -ForegroundColor Red "FAILED "
Write-Host -ForegroundColor DarkBlue "PowerShell major version 3 is required, you use version $($PSVersionTable.PSVersion.Major)"
}
Check-FolderFile -FileName "Library.ps1" -FileDescription "DNGToolKit function library"
Check-FolderFile -FileName "Settings.xml" -FileDescription "Configuration XML-file"
Check-FolderFile -FilePath "$dng_exec_path" -FileDescription "Adobe DNG Converter installation"
Check-FolderFile -FilePath "$convert_root_path" -FileDescription "Convertation path"
Check-FolderFile -FilePath "$workplace_root_path" -FileDescription "Workplace path"
Write-Host ""
Write-Host "$($disclaimer)"
Write-Host ""
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
# Generate menu
$OptionArray = @("Copy RAW/ARW-files from SD-Card","Copy RAW/ARW-files from SD-Card & Convert","Move RAW/ARW-files from SD-Card","Move RAW/ARW-files from SD-Card & Convert","Convert ARW to DNG","Delete unused RAW/ARW-files","Delete ARW from memory card (attention)","Quit and exit")
$Banner = "
DNGToolKit
Latest version: https://github.com/filipnet/dngtoolkit
Author: Benedikt Filip
License: DNG ToolKit and all individual scripts are under the BSD 3-Clause license
-----------------------------------------------------------"
do {
$MenuResult = Create-Menu -MenuTitle $Banner -MenuOptions $OptionArray
Switch($MenuResult){
0{
# Copy RAW/ARW-files from SD-Card
Transfer-SDtoDisk -ActionType Copy
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
1{
# Copy RAW/ARW-files from SD-Card & Convert
Transfer-SDtoDisk -ActionType Copy
Convert-ARWtoDNG
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
2{
# Move RAW/ARW-files from SD-Card
Transfer-SDtoDisk -ActionType Move
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
3{
# Move RAW/ARW-files from SD-Card & Convert
Transfer-SDtoDisk -ActionType Move
Convert-ARWtoDNG
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
4{
# Convert ARW to DNG
Convert-ARWtoDNG
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
5{
# Delete unused RAW/ARW-files
Write-Host -BackgroundColor Blue "Delete unused RAW/ARW-files"
$arw = Get-ChildItem -r -force -include *.arw -ErrorAction SilentlyContinue $workplace_root_path | Sort-Object -Unique
Clear-Host
foreach ($rawFile in $arw) {
$dngFile = join-path $rawFile.DirectoryName "$($rawFile.BaseName).DNG"
if (Test-Path $dngFile) {
Write-Host -NoNewline "DNG for $rawFile exist: "
Write-Host -ForegroundColor Green "KEEP"
} else {
Write-Host -NoNewline "DNG for $rawFile not exist: "
Write-Host -ForegroundColor Red "DELETE"
remove-item $rawFile
}
}
Write-Host "Deleting empty folders" -ForegroundColor Red
Get-ChildItem $workplace_root_path -Recurse | Where-Object{$_.PSIsContainer -and !(Get-ChildItem $_.Fullname -Recurse | Where-Object{!$_.PSIsContainer})} | Format-Table Name,CreationTime,LastAccessTime,LastWriteTime -AutoSize
Remove-EmptyFolders $workplace_root_path
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
6{
# Delete ARW from memory card
Write-Host -BackgroundColor Blue "Delete RAW/ARW-files from memory card"
$confirmation = Read-Host -Prompt 'Are you really sure you would like to delete all photos from your memory card? Type YES and press enter'
if ($confirmation -contains "YES") {
Write-Host "Your confirmation input was [$confirmation]" so all photos from your memory card would be erased.
$arw = Get-ChildItem -r -force -include *.arw -ErrorAction SilentlyContinue $src_volume_import | Sort-Object -Unique
Clear-Host
foreach ($rawFile in $arw) {
Write-Host -NoNewline "$rawFile : "
Write-Host -ForegroundColor Red "DELETE"
remove-item $rawFile
}
} else {
Write-Warning -Message "Your input is not valid"
}
[System.Media.SystemSounds]::Beep.Play();
Write-Host "Press any key to continue ....."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
7{
# Quit and exit
exit
}
Default{
# Quit and exit
exit
}
}
} while ($MenuResult -ne 7)