首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >批处理文件将大量文本-Copying到.txt文件中

批处理文件将大量文本-Copying到.txt文件中
EN

Stack Overflow用户
提问于 2012-09-06 06:51:16
回答 2查看 289关注 0票数 0

我想要它,所以当我点击一个批处理文件时,它会将很多东西复制到批处理文件中,我尝试过使用>>方法( echo example>>example.txt ),但它只复制了我想要复制的内容的一半,我有很多行,所以我想知道是否有最多的行要复制,如果没有为什么它没有复制我想要复制的所有东西?(我希望它复制大约150行)编辑:这是我正在尝试做的事情:

代码语言:javascript
复制
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

到目前为止,它还不起作用。

EN

回答 2

Stack Overflow用户

发布于 2012-09-06 08:08:23

大多数人这样做是错误的,在脚本中有100个echo语句,每行一个,但有一种更好的方法。最好的方法是:

代码语言:javascript
复制
@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
票数 1
EN

Stack Overflow用户

发布于 2012-09-08 04:43:50

当您尝试使用<>字符时,您的代码会失败,但这些字符是批处理的特殊字符(它们是为重定向保留的)。

但是您可以避开它们,另外,您应该对echo命令使用延迟扩展,以避免出现同样的问题。

代码语言:javascript
复制
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语句

代码语言:javascript
复制
(
  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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12290854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档