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.

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104

1 Answers1

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
Community
  • 1
  • 1
shaochuancs
  • 15,342
  • 3
  • 54
  • 62
  • 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. – Pranav Singh Mar 14 '17 at 11:06
  • In `for` statement, `/r` means *recursive*, which gets all files inside subfolder into consideration. Refer to https://technet.microsoft.com/en-us/library/bb490909.aspx – shaochuancs Mar 14 '17 at 13:45
  • @PranavSingh is your question correctly answered? If yes, maybe you can "accept" this answer? – shaochuancs May 03 '17 at 03:18
  • sorry for late response, I moved away with some other solution & never tried this. Thanks for ur help – Pranav Singh Jun 06 '17 at 08:59