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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With