-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path[ImageMagick] Convert webp to jpg [Drop directory on].bat
More file actions
80 lines (53 loc) · 1.74 KB
/
Copy path[ImageMagick] Convert webp to jpg [Drop directory on].bat
File metadata and controls
80 lines (53 loc) · 1.74 KB
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
@Echo OFF
SetLocal EnableDelayedExpansion
Rem // 7-Zip Executable Path
Set imageMagick="C:\tools\ImageMagick-x64\bin\magick.exe"
Rem // START: NewLine Variable Hack
Set newLine=^
Rem // END: NewLine Variable Hack !! DO NOT DELETE 2 EMPTY LINES ABOVE !!
Rem // Set ErrorLog Variables
Set errorCount=0
Set separator=--------------------------------------------------------
Set errorLog=!newLine!!separator!!newLine!!newLine!
Set errorPrefix=ERROR @:
Set successMessage=All Files Were Successfully Converted
Rem // Loop Through Each Argument
SetLocal DisableDelayedExpansion
for %%x in (%*) do (
Rem // Use Current Argument To set File, Folder Paths
SetLocal DisableDelayedExpansion
Set filePath="%%~x"
Set directoryFiles="%%~x\*"
SetLocal EnableDelayedExpansion
Rem // Source Is A Folder
if exist !directoryFiles! (
Set sourcePath=!directoryFiles!
)
Rem // Source Is A File
if not exist !directoryFiles! (
Set sourcePath=!filePath!
)
Rem // Print Separator To Divide Output
echo !newLine!!separator!!newLine!
Rem // Make output directory
if not exist OUTPUT (
mkdir OUTPUT
echo OUTPUT Directory created
echo !newLine!!separator!!newLine!
)
Rem // Convert files
echo Converting: !filePath!
!imageMagick! mogrify -format JPEG -path OUTPUT *.webp !sourcePath!
Rem // Log Errors
if ErrorLevel 1 (
Set /A errorCount=errorCount+1
Set errorLog=!errorLog!!newLine!!errorPrefix!!sourcePath!
)
)
Rem // Print ErrorLog
if !errorCount!==0 (
Set errorLog=!errorLog!!newLine!!successMessage!
)
Echo !errorLog!!newLine!!newLine!!newLine!
Rem // Keep Window Open To View ErrorLog
pause