-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasset-helper.cmd
90 lines (73 loc) · 2.48 KB
/
asset-helper.cmd
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
@echo off
rem Set a local scope, allowing for delayed expansion of variables
setlocal EnableDelayedExpansion
rem Get the directory where the script resides using %~dp0
set "search_dir=%~dp0"
rem Define a blacklist of directories not to process
set "blacklist=pwa"
rem Loop through all files with "-min" in the filename in the script directory and its subdirectories
echo Searching for minified files...
echo.
for /R "%search_dir%" %%i in (*-min.*) do (
set "skipFile="
rem Check if the directory is in the blacklist
for %%b in (%blacklist%) do (
rem check if %%~dpi starts with %%b using findstr & update skipFile to 1 if true
echo %%~dpi | findstr /I /C:"%%b" > nul
if not errorlevel 1 (
set "skipFile=1"
)
)
rem If skipFile variable is not defined, indicating the directory is not in the blacklist
if not defined skipFile (
rem Extract filename without extension
set "filename=%%~ni"
rem Output the full path, filename, and extension of each file
echo Deleting Minified File: %%i
@REM echo Filename without extension: !filename!
@REM echo File Extension: %%~xi
rem Remove all files with the -min suffix
del "%%i"
)
)
rem Loop through all image files in the script directory and its subdirectories
echo.
echo Searching for image files...
echo.
for /R "%search_dir%" %%i in (*.png *.jpg *.jpeg) do (
set "skipFile="
for %%b in (%blacklist%) do (
rem check if %%~dpi starts with %%b using findstr & update skipFile to 1 if true
echo %%~dpi | findstr /I /C:"%%b" > nul
if not errorlevel 1 (
set "skipFile=1"
)
)
if not defined skipFile (
echo Minifiying Image: %%i
ffmpeg -loglevel quiet -y -i "%%i" -vf scale=20:20 "%%~dpi%%~ni-min%%~xi"
)
)
rem Loop through all video files in the script directory and its subdirectories
echo.
echo Searching for video files...
echo.
for /R "%search_dir%" %%i in (*.mp4 *.webm *.ogg) do (
set "skipFile="
for %%b in (%blacklist%) do (
rem check if %%~dpi starts with %%b using findstr & update skipFile to 1 if true
echo %%~dpi | findstr /I /C:"%%b" > nul
if not errorlevel 1 (
set "skipFile=1"
)
)
if not defined skipFile (
set "filename=%%~ni"
echo Video File: %%i
echo Filename without extension: !filename!
echo File Extension: %%~xi
)
)
endlocal
echo.
pause