in reply to Re^2: Combining files
in thread Combining files

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 (κς,πμ,πλ)

Replies are listed 'Best First'.
Re^4: Combining files
by vitoco (Hermit) on Oct 02, 2009 at 13:37 UTC

    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.

Re^4: Combining files
by ikegami (Patriarch) on Oct 02, 2009 at 14:52 UTC
    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

Re^4: Combining files
by marto (Cardinal) on Oct 02, 2009 at 12:18 UTC

    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.

Re^4: Combining files
by Aim9b (Monk) on Oct 02, 2009 at 23:35 UTC
    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.