Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I currently have this command:

copy /b *.txt newfile.txt

But I want to include all files with folders as well.

  • How can I do this? Is it possible to add this to Apache Ant as well?

I also consider doing this to minify JS files.

  • Is there anyway to remove lines as well?
  • Is there a better command to use than the one I am currently using?

CURRENT CODE

<target name="concatenate" description="Concatenate all js files">
    <concat destfile="build/application.js">
        <fileset dir="js" includes="**/*.js" />
    </concat>
</target>
<target name="compress" depends="concatenate" description="Compress application.js to application-min.js">
    <apply executable="java" parallel="false">
        <filelist dir="build" files="application.js" />
        <arg line="-jar" />
        <arg path="C:\yuicompressor-2.4.7\build\yuicompressor-2.4.7.jar" />
        <srcfile />
        <arg line="-o" />
        <mapper type="glob" from="*.js" to="build/*-min.js" />
        <targetfile />
    </apply>
</target>
share|improve this question
    
What OS are you using? –  EBGreen Aug 1 '12 at 13:51
    
Windows 7 latest –  Liam McCann Aug 1 '12 at 13:52
    
You ask if there is a better command. If the one you have is working, I'm not sure what you mean by better. Also, what lines would you want to take out? –  EBGreen Aug 1 '12 at 13:56
    
Won't the YUI compressor remove unneeded blank lines already? –  Mechanical snail Aug 1 '12 at 13:57
add comment

1 Answer

On a nix OS you can use:

 find | xargs cat | sed ':a;N;$!ba;s/\n/ /g'

This will first find all files under the current folder, than concatenate them and than remove new line characters with sed script that adds lines to a register without the new line.

I suspect from the use of copy command that you are using Windows, you will have to find the windows equivalents to the nix commands.
find for example can be replaced with dir /s /b. type might be a fine replacment for cat. etc.

Or you can have a look in this answer http://stackoverflow.com/questions/127318/is-there-any-sed-like-utility-for-cmd-exe that explain how to use nix command tools on windows.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.