Say i have the following files in a directory
how can i write a batch for loop such that all ".js" files are picked up but ".min.js" are not and the output of the .js filename can be changed to append .min.js
eg:
for %%A IN (*.js) DO @echo %%A "->" %%~nA ".min.js"
would ideally produce the following, and note the file2.min.js is not displayed to the left.
Thanks for your help.
Just look whether it already contains .min.js
:
setlocal enabledelayedexpansion
for %%f in (*.js) do (
set "N=%%f"
if "!N:.min.js=!"=="!N!" echo %%f -^> %%~nf.min.js
)
Not that I disagree with @Joey's solution, but I thought it wouldn't hurt if I posted an alternative:
@ECHO OFF
FOR %%f IN (*.js) DO (
FOR %%g IN ("%%~nf") DO (
IF NOT "%%~xg" == ".min" ECHO "%%f" -^> "%%~g.min.js"
)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With