这是一个普通的 .bat ,它连接所有行并在结果字符串之间留下一个空格。
@echo off
setlocal EnableDelayedExpansion
set row=
@For /F "EOL=|" %%x In ('^""%__AppDir__%find.exe" "."^<"%userprofile%\i.txt"^"') Do @Set "row=!row! %%x"
echo %row% >%userprofile%\o.txt
echo %row%
这是该脚本的测试输入:
PDF
wikkipedia.ord
notavalidURL
snapfish.com
.tunnelbear.com
mail.google.com/mail/u/0/#inbox
它输出,完全可以预见:
wikkipedia.ord snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox!
但这是另一个行为方式不同的输入:
PDF
Tech
TORONTO
>
SOME PERSON
Some Company
BusinessName
User Name
Users
Default User
Default Filter Profile
Web Exceptions
BackWeb Exceptions
Applied URL Lists
Attach List
Individual Exceptions
Applied individually to User and can be modified
Individual List32 URLs
BBC Weather
Shared ListTechloq7 URLs
Bing Search
Allows "bing" search
Shared ListTechloq45 URLs
Business Essential Sites
pre-approved business sites, (from reference, Technology, File sharing, shopping etc).
Shared ListTechloq167 URLs
Email [Gmail]
Allow Gmail Yahoo and AOL mail.
Shared ListTechloq77 URLs
Google Drive
Shared ListTechloq35 URLs
Google hangouts
Shared ListTechloq8 URLs
Google Maps
Shared ListTechloq33 URLs
Google Photos
Shared ListTechloq5 URLs
Jewish Music
Shared ListTechloq89 URLs
Jewish Websites
Allows all jewish websites.
Shared ListTechloq1183 URLs
Microsoft [and google] Office blacklist
Blocks in app browsing for Microsoft apps [office 365, start menu etc.] and for google docs.
Shared ListTechloq18 URLs
Microsoft Classroom
Shared ListTechloq25 URLs
Microsoft maps app
Allows the Microsoft map app
Shared ListTechloq1 URLs
Microsoft Online
Shared ListTechloq27 URLs
Microsoft Teams
Shared ListTechloq28 URLs
Mostlymusic.com
Shared ListTechloq17 URLs
Office Activate
Activate Microsoft office
Shared ListTechloq7 URLs
Religious Blacklist
Blocks ëôéøä websites.
Shared ListTechloq23 URLs
Techloq Global List
For back end and content servers [recaptcha etc.]
Shared ListTechloq261 URLs
Torah Websites
Shared ListTechloq115 URLs
Windows Store blacklist
Shared ListTechloq12 URLs
Windows Update
You might need to add .microsoft.com to the ssl list.
Shared ListTechloq16 URLs
Yahoo Search
Allows Yahoo search
Shared ListTechloq42 URLs
Individual Exceptions
Applied individually to User and can be modified
Individual ListLast changed Dec 26, 2019 09:35 AM
URLs Included
Access
Offensive Text Filter
Images Filter
Video Blocking
Type URL and press Enter
On
On
On
wikkipedia.ord
Time left 13d 34m
Go to Temporary Access
youtubedownload.video
On
On
Off
.slack.com
Off
Off
Off
slack.com
Off
Off
Off
snapfish.com
On
Off
On
.tunnelbear.com
On
On
Off
mail.google.com/mail/u/0/#inbox
On
Off
Off
google.com/url?q=https://connect.cloudberrylab.com?i%3D448781782&source=gmail&ust=1573146628917000&usg=AFQjCNF14Y-dux0_bNSOc-jOfjLgHy-3fw
On
On
On
connect.cloudberrylab.com?i=448781782
On
Off
Off
golantelecom.co.il
On
On
Off
msn.com
citibank.com
On
On
Off
youtube.com/watch?v=TsBcex3M2Xo&list=RDTsBcex3M2Xo&start_radio=1&t=0
On
Off
Off
youtube.com/watch?v=TsBcex3M2Xo&list=PL8CN8XjdSyu0TdNKo9U9sF1RL7NB3_0mh
On
Off
Off
ontimestudios.com
On
Off
Off
ontimerovideo.com
On
Off
Off
badchen.com
On
Off
Off
ebay.com/
On
On
On
offshorecompany.com
On
On
On
offshorecompany.com/company/israel-llc/
On
On
On
wikipedia.org
On
On
On
ravkavonline.co.il
On
On
On
tunnelbear.com
On
On
On
citiprivatepass.com
On
On
On
docs.google.com
On
On
On
play.google.com
On
On
On
myjewishcolorado.org
On
On
On
hillelacademyofdenver.com/
On
On
On
wikkipedia.com
On
On
On
productforums.google.com
On
On
On
ultrasurf.us
On
On
On
stackoverflow.com
On
On
On
tutorialpoint.com
On
On
On
Dec 29, 2019 12:23 AM
它会输出一些相当烦人的东西:
pre-approved business sites, (from reference, Technology, File sharing, shopping etc). Allow Gmail Yahoo and AOL mail. Allows all jewish websites. Blocks in app browsing for Microsoft apps [office 365, start menu etc.] and for google docs. Mostlymusic.com Blocks δ⌠Θ°Σ websites. For back end and content servers [recaptcha etc.] You might need to add .microsoft.com to the ssl list. wikkipedia.ord youtubedownload.video .slack.com slack.com snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox google.com/url?q=https://connect.cloudberrylab.com?i%3D448781782
'source' is not recognized as an internal or external command,
operable program or batch file.
'ust' is not recognized as an internal or external command,
operable program or batch file.
'usg' is not recognized as an internal or external command,
operable program or batch file.
'list' is not recognized as an internal or external command,
operable program or batch file.
'start_radio' is not recognized as an internal or external command,
operable program or batch file.
'1' is not recognized as an internal or external command,
operable program or batch file.
'list' is not recognized as an internal or external command,
operable program or batch file.
为什么这个字符串不同,我如何更改我的 .bat 以获得与第一次尝试相同类型的输出?
以下是似乎与错误相关的刺痛:
'source' is not recognized as an internal or external command
operable program or batch file.
google.com/url?q=https://connect.cloudberrylab.com?i%3D448781782&source=gmail&ust=1573146628917000&usg=AFQjCNF14Y-dux0_bNSOc-jOfjLgHy-3fw
'ust' is not recognized as an internal or external command
operable program or batch file.
google.com/url?q=https://connect.cloudberrylab.com?i%3D448781782&source=gmail&ust=1573146628917000&usg=AFQjCNF14Y-dux0_bNSOc-jOfjLgHy-3fw
'usg' is not recognized as an internal or external command
operable program or batch file.
google.com/url?q=https://connect.cloudberrylab.com?i%3D448781782&source=gmail&ust=1573146628917000&usg=AFQjCNF14Y-dux0_bNSOc-jOfjLgHy-3fw
'list' is not recognized as an internal or external command,
operable program or batch file.
youtube.com/watch?v=TsBcex3M2Xo&list=RDTsBcex3M2Xo&start_radio=1&t=0
'start_radio' is not recognized as an internal or external command,
operable program or batch file.
youtube.com/watch?v=TsBcex3M2Xo&list=RDTsBcex3M2Xo&start_radio=1&t=0
'1' is not recognized as an internal or external command,
operable program or batch file.
youtube.com/watch?v=TsBcex3M2Xo&list=RDTsBcex3M2Xo&start_radio=1&t=0
'list' is not recognized as an internal or external command,
operable program or batch file.
youtube.com/watch?v=TsBcex3M2Xo&list=PL8CN8XjdSyu0TdNKo9U9sF1RL7NB3_0mh
查看输出我可以看到所有引发错误的单词都位于一个字符旁边&
(如果这对任何人都意味着什么)。
更令人沮丧的是,我专门编写了这段代码,以便处理来自某个网站的文本。每次我将该站点的页面复制到记事本并运行我的代码时,都会发生同样的事情,所以在我解决这个问题之前我什么都没有
我试图避免使用 CMD 以外的任何代码(即 powershell、cygwin、paste.exe)
您忘记了 bat/cmd 作业在字符串操作中的重要内容...
您的文件多次出现
您可以使用
set /p "'="
在文件中获取此输出而无需转义特殊字符,因为此命令使用引号:set /p
"'=!row!
"选项 #1 - == 搜索。(字面点)
find.exe "."
选项#2 - == 搜索任何(正则表达式任何字符)
findstr.exe .
对不起我的有限