3

here is an ordinary .bat that joins all lines and leaves a whitespace between the resulting strings.

@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%

here is test input for that script:

PDF

wikkipedia.ord
notavalidURL
snapfish.com
.tunnelbear.com
mail.google.com/mail/u/0/#inbox

it outputs, quite predictably:

wikkipedia.ord snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox!

but here is another input that does not behave the same way:

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

it outputs something rather annoying like this:

 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.

why is this string different and how can i change my .bat to get the same type of output as the first attempt?

here are the stings that seem to be associated with the errors:

'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

looking at the output i can see that all the words that threw errors are sitting next to an & character (if that means anything to anyone).

what's more upsetting is that i specifically wrote this code in-order to process text from a certain website. every time i copy a page from that site into notepad and run my code the same thing happens so i have nothing until i fix this enter image description here

i am trying to avoid using any code that is not native to CMD (ie powershell, cygwin, paste.exe)

1 Answers1

2

  • You forgot something important in string actions by bat/cmd jobs...

    You need to use escape for specials characters ..., &, ?, >, etc,....

  • Your file has many occurrences


You can use set /p "'=" to get this output in a file without having to escape special characters, because this command are using quotes: set /p"'=!row!"


echo %row%       >%userprofile%\o.txt
|| instead: ||
set /p "'=!row!" >"%userprofile%\o.txt"

  • Option #1 - find.exe "." == search . (literal dot)


  • Option #2 - findstr.exe . == search any (Regex any character)



  • If you need Option #1:

@echo off && setlocal enabledelayedexpansion

cls & title ..\%~nx0 && pushd %userprofile%
set "_row="<nul && for /f eol^=^| %%x in ('
^""%__appdir__%findstr.exe" . ^<".\i.txt"^"
')do set "_row=!_row! %%x"

>"%userprofile%\o.txt" set/p "'=!_row!"<nul
echo[!_row! && podp && endlocal && ;exit /b 

  • Option #1 results:
pre-approved Allow Allows Blocks Mostlymusic.com Blocks For You 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=gmail&ust=1573146628917000&usg=AFQjCNF14Y-dux0_bNSOc-jOfjLgHy-3fw connect.cloudberrylab.com?i=448781782 golantelecom.co.il msn.com citibank.com youtube.com/watch?v=TsBcex3M2Xo&list=RDTsBcex3M2Xo&start_radio=1&t=0 youtube.com/watch?v=TsBcex3M2Xo&list=PL8CN8XjdSyu0TdNKo9U9sF1RL7NB3_0mh ontimestudios.com ontimerovideo.com badchen.com ebay.com/ offshorecompany.com offshorecompany.com/company/israel-llc/ wikipedia.org ravkavonline.co.il tunnelbear.com citiprivatepass.com docs.google.com play.google.com myjewishcolorado.org hillelacademyofdenver.com/ wikkipedia.com productforums.google.com ultrasurf.us stackoverflow.com tutorialpoint.com


  • If you need Option #2:
@echo off && setlocal enabledelayedexpansion

cls & title ..\%~nx0 && pushd %userprofile%
set "_row="<nul && for /f eol^=^| %%x in ('
^""%__appdir__%findstr.exe" . ^<".\i.txt"^"
')do set "_row=!_row! %%x"

>"%userprofile%\o.txt" set/p "'=!_row!"<nul
echo[!_row! && podp && endlocal && ;exit /b

  • Option #2 results:
PDF TechLog TAG > SOME Some BusinessName User Users Default Default Web BackWeb Applied Attach Individual Applied Individual BBC Shared Bing Allows Shared Business pre-approved Shared Email Allow Shared Google Shared Google Shared Google Shared Google Shared Jewish Shared Jewish Allows Shared Microsoft Blocks Shared Microsoft Shared Microsoft Allows Shared Microsoft Shared Microsoft Shared Mostlymusic.com Shared Office Activate Shared Religious Blocks Shared Techloq For Shared Torah Shared Windows Shared Windows You Shared Yahoo Allows Shared Individual Applied Individual URLs Access Offensive Images Video Type On On On wikkipedia.ord Time Go 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


  • File ".\i.txt" contents:
PDF
TechLog
TAG 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

Sorry my limited

Io-oI
  • 9,237