1

I have multiple minified files in multiple folder in a single folder for minified js.

I wish to create single js file from all of minified js. Now I am using type command to concatenate all files like

type .\\v2\\dist\\js\\*.js >> .\\build\\a.min.js   &&   type .\\v2\\dist\\js\\config\\*.js >> .\\build\\a.min.js && ... 

Like wise I need to append all recursive folders. Is there any clean way to do it.

Please don't suggest using Gulp or Grunt as we are already in process of removing them & using Webpack. Any code using webpack or using npm or simple command line is welcome.

2
  • Possible duplicate with stackoverflow.com/questions/24069173/… Commented Mar 10, 2017 at 10:09
  • 1
    I'm on windows not linux. Those commands are not available in windows Commented Mar 14, 2017 at 6:29

1 Answer 1

2

If on Windows, you can use command line like below (refer to @dbenham's answer):

for /r "c:\javascripts" %F in (*.js) do @type "%F" >>concatenated.js

If on Linux or Mac, you can use find:

find ./v2/dist/js/ -name '*.js' -exec cat {} \; > ./build/a.min.js
Sign up to request clarification or add additional context in comments.

4 Comments

Files are in multiple folders & there are folder inside folders. As I mentioned in question, type can take all js files inside a folder without for loop using *.js with folder path but no way for having all files inside subfolders inside the folder too.
In for statement, /r means recursive, which gets all files inside subfolder into consideration. Refer to technet.microsoft.com/en-us/library/bb490909.aspx
@PranavSingh is your question correctly answered? If yes, maybe you can "accept" this answer?
sorry for late response, I moved away with some other solution & never tried this. Thanks for ur help

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.