Frage

I have a windows batch file which takes a file, runs it through a compiler to minify the file, then spits it back out. My question is, how can I rename the file like so:

I want it to go from script.js to script.min.js

I am using the below script:

@ECHO OFF
ECHO.
FOR %%c in (C:\source\*.*) DO java -jar ./Compiler/compiler.jar %%c --js_output_file %%c.min.js
ECHO.
PAUSE
CLS
EXIT

When I use the script, it outputs the file with a filename of script.js.min.js so I was hoping that I could just cut out the .js first, and then append the .min.js afterward.

UPDATE:

If there is a way to output the name of the file then append .min.js I think I would prefer that.

War es hilfreich?

Lösung

FOR %%c in (C:\source\*.*) DO java -jar ./Compiler/compiler.jar %%c --js_output_file %%~dpnc.min.js

The ~dpn selects just the drive,path,name portions and omits the extension (x)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top