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.

2
  • Your "Unix script" appears to be a Windows batch file. What version or Unix or Linux are you on? Or are you? Commented Feb 10, 2014 at 23:09
  • @NedNowotny Yep. Don't know much about unix or batch files. It looks like it's a Windows batch file. Commented Feb 10, 2014 at 23:25

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.