开发者

an arrow → character getting appeded to files in a .bat script

The following script gets all files with .new_tmp extension and copies them to a file with the same name but without the .new_tmp extension. In addition a comment is placed at the top of the file and the .new_tmp file is deleted.

echo ^<?php /* > start.tmp
echo */ ?^> > end.tmp
for /R "./mydir" %%I in (*.new_tmp) do (
    copy start.tmp+license.txt+end.tmp+%%I worker.tmp
    move worker.tmp %%~pI%%~nI
    del %%I
)

The problem is that a right facing arrow → gets appended to the bottom of all the files

Why is this character getting appended to the end of all the files?

UPDATE I tried this with a much simpler example and got the same results

copy NUL worker.tmp
copy worker开发者_开发百科.tmp + license.txt + license.txt + license.txt

Same problem, an arrow at the end...

I am running under Windows 7


The arrow is a CTRL-Z ascii char that is appended by the COPY command when used to concatenate files with the + option.

To prevent COPY to append the CTRL-Z character, use COPY /B for a binary copy.

So, your command would be

COPY /B start.tmp+license.txt+end.tmp+%%I worker.tmp


When /b follows Destination, copy does not add an end-of-file character.

This is how I would solve the problem:

COPY start.tmp+license.txt+end.tmp+%%I worker.tmp /B
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜