Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7976953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:03:13+00:00 2026-06-04T09:03:13+00:00

I am trying to write a batch script that combines several css files into

  • 0

I am trying to write a batch script that combines several css files into one file. So far I have come up with this…

# Set start folders & files
set fn1=filename.css
set fn2=another-filename.css
set fn3=yet-another-filename.css

# get filename add to temp file inside comment syntax
echo /* %fn1% >>  tmp.css
echo. --------------------------------------------------------------- */ >>  tmp.css
echo. >>  tmp.css

# copy file contents
copy/b %fn1% + tmp.css

# repeat with other files...

echo /* %fn2% >>  tmp.css
echo. --------------------------------------------------------------- */ >>  tmp.css
echo. >>  tmp.css
copy/b %fn2% + tmp.css

...

rename tmp.css  combined-files.css
move combined-files.css \new-folder\combined-files.css

Problem is it produces the following

/* filename.css
--------------------------------- */
/* another-filename.css
--------------------------------- */
/* ... */

[styles from filename.css]
[styles from another-filename.css]
....

Where am I going wrong with this?

Thanks

p.s. my attempts to simplify the above using ms-dos FOR command are pretty naff as well.

set commentpt1=\*
set commentpt2=----------------------------------------- *\

FOR /F %%I IN ('DIR /s C:\[folder location]') DO echo %commentpt1% %%~nI 0x0A %commentpt2% 0x0A 0x0A >> temp.css copy/b %%I + tmp.css >> temp.css
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:03:15+00:00Added an answer on June 4, 2026 at 9:03 am

    Your primary problem is you have reversed the order of the file names in your COPY /B command. A side effect of this problem is you are modifying your original files!

    You probably don’t want to see the output of your COPY /B command, so you could redirect to nul.

    There is no need to rename your temp file before moving it.

    In fact, why use a temp file at all? Why not write directly to your desired destination file?

    I would put the blank line after the file contents, not before. I think it looks better.
    It is safer to use echo( instead of echo..

    But… there is a much simpler and cleaner method to do what you want.

    @echo off
    (
      for %%F in (
        "filename.css"
        "another-filename.css"
        "yet-another-filename.css"
      ) do (
        echo /* %%~F
        echo --------------------------------------------------------------- */
        type %%F
        echo(
      )
    )>"\new-folder\combined-files.css"
    

    If you want to combine all .css files in the folder, then it is even simpler:

    @echo off
    (
      for %%F in ( *.css ) do (
        echo /* %%~fF
        echo --------------------------------------------------------------- */
        type "%%~fF"
        echo(
      )
    )>"\new-folder\combined-files.css"
    

    The above processes the current directory, but you could include path info in the IN() clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a windows batch file that can delete files from subdirectories.
I'm trying to write a small batch script that will delete files old files
I'm trying to write two batch files that will allow me to switch the
I am trying to modify a batch script that installs a simple script file
I am trying to write a batch file that exists in an arbitrary directory
I am trying to write a script that will parse a local file and
I'm trying to write a batch script that errors if port 1099 is already
I'm trying to write a batch script (CMD @ Windows XP Pro) that will
I am trying to write a batch file that starts another batch file ,
I'm trying to write a batch file that takes the drive letter the batch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.