0

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.

neuquen
  • 3,991
  • 15
  • 58
  • 78
  • Your "Unix script" appears to be a Windows batch file. What version or Unix or Linux are you on? Or are you? – Ned Feb 10 '14 at 23:09
  • @NedNowotny Yep. Don't know much about unix or batch files. It looks like it's a Windows batch file. – neuquen Feb 10 '14 at 23:25

1 Answers1

3
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)

Magoo
  • 77,302
  • 8
  • 62
  • 84