0

バッチファイルをクリックすると、たくさんのものがバッチファイルにコピーされます。>>メソッド(echo example >> example.txt)を使用してこれを試しましたが、必要なものの半分しかコピーされません。コピーするために、私はたくさんの行を持っているので、コピーする行が最大であるかどうか、そしてコピーしたいものすべてをコピーしない理由がないのではないかと思っていましたか?(約150行をコピーしたい)編集:これは私がやろうとしていることです:

SET FILECONTENTS=1.) In the url of the item you want to use the buy button on, Put Javascript:startbuy();^  
 2.) Inspect element on buy button.^  
 3.) Put the code at the bottom in it.^  
 4.) You now no longer need to refresh once the item goes onsale.^  
 <input type="submit" class="newPurchaseButton" value=""^  
ECHO %FILECONTENTS%>>testingfile.txt

これまでのところ、それは機能しません。

4

2 に答える 2

1

ほとんどの人は、1 行に 1 つずつ、スクリプトに 100 の echo ステートメントを含めるという間違った方法でこれを行っていますが、もっと良い方法があります。これを行う最良の方法は次のとおりです。

@echo off
setlocal EnableDelayedExpansion
set "LA=^<"
set "RA=^>"
:: 2 blank lines required below set NLM !
set NLM=^


set NL=^^^%NLM%%NLM%^%NLM%%NLM%

SET FILECONTENTS=^
 1.) In the url of use the buy button on, Put Javascript:startbuy();!NL!^
 2.) Inspect element on buy button.!NL!^
 3.) Exclamation^^! Put the code at the bottom in it.!NL!^
 4.) You now no longer need to refresh once the item goes onsale.!NL!^
 !LA!input type=^"submit^" class=^"newPurchaseButton^" value=^"^"!RA!

ECHO %FILECONTENTS%
ECHO %FILECONTENTS%>>test.txt     
pause
于 2012-09-06T00:08:23.323 に答える
1

文字を使用しようとするとコードは失敗しますが<>、これらはバッチ用の特別な文字です (リダイレクト用に予約されています)。

ただし、それらをエスケープすることができます。さらに、同じ問題を回避するために、echo コマンドに遅延展開を使用する必要があります。

setlocal EnableDelayedExpansion
SET FILECONTENTS=^
 1.) In the url of the item you want to use the buy button on, Put Javascript:startbuy();^
 2.) Inspect element on buy button.^
 3.) Put the code at the bottom in it.^
 4.) You now no longer need to refresh once the item goes onsale.^
 ^<input type="submit" class="newPurchaseButton" value=""^>

>>testingfile.txt ECHO !FILECONTENTS!

編集:別の方法

改行も作成したい場合は、ブロックで単純な echo ステートメントを使用できます

(
  echo 1.^) In the url of the item you want to use the buy button on, Put Javascript:startbuy(^);
  echo 2.^) Inspect element on buy button.
  echo 3.^) Put the code at the bottom in it.
  echo 4.^) You now no longer need to refresh once the item goes onsale.
  echo ^<input type="submit" class="newPurchaseButton" value=""^>
) > testingfile.txt

より多くのソリューションについては、 SO:Splitting Doublequoted Line Into Multiple Lines in Windows Batchを読むことができます

于 2012-09-07T20:43:49.997 に答える