in reply to Re: Combining files
in thread Combining files

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Combining files
by massa (Hermit) on Oct 02, 2009 at 12:10 UTC
    cmd.exe (AKA Command Prompt) is backwards-compatible with DOS's command.com, and so is the
    type * > ..\newfile
    suggested command. But, as TIMTOWTDI:
    perl -pe '' * > ..\newfile
    will work too :-D
    []s, HTH, Massa (κς,πμ,πλ)

      AFAIK, wildcards in OS boxes are expanded by programs, not by the shell (cmd.exe) as in *nix. Perl will keep "*" as an argument, and it's illegal as a filename when interpreted by <> operator.

      You may consider this:

      FOR %F IN (*) DO perl -pe "" "%F" >> ..\newfile.txt

      but it's better to use Win's built-in commands, like TYPE or COPY, as it was already said.

      Note that newfile.txt must be empty or must not exists before the FOR, because >> opens it for append on each iteration.

      Update: Using globs:

      perl -e "while (<*>) {open(F,$_) or next;while(<F>){print}/}}" > ..\ne +wfile.txt

      Note: this code has errors, but works as an example.

      BTW, it seems that files order is not important.

      Sorry bud, but neither of those work.

      Perl will fail to find a file named "*". You need the following if you were using Perl:

      perl -MFile::Glob -pe"BEGIN{ @ARGV = map bsd_glob($_), @ARGV }" *.* >. +.\newfile

      type displays the file name when using wildcards, so it's not good here. The DOS way is the "+" syntax of copy

      I understand that the command will work via the command prompt, I was pointing out that modern Windows operating systems don't come with Microsoft DOS.

      Also please make updates obvious (for example 'Update update to post....') when you add something to a post.

      Update: fixed typo.

      Thank you. I didn't realize that MS finally "fixed" their TYPE file concatenation issue. I've been burned by it & so I always just used COPY + and stayed away from it. Thanks.