Sorting 排序URL的批处理文件
我需要创建批处理文件,如以下示例所示: ▬ 谷歌网站▬ ▬ 雅虎网站▬ ▬ 必应网▬ 另外,我在link.txt中有更多关于这个url的链接Sorting 排序URL的批处理文件,sorting,batch-file,url,Sorting,Batch File,Url,我需要创建批处理文件,如以下示例所示: ▬ 谷歌网站▬ ▬ 雅虎网站▬ ▬ 必应网▬ 另外,我在link.txt中有更多关于这个url的链接 http://drive.google.com http://gallery.bing.com http://mail.yahoo.com http://video.google.com http://brb.yahoo.com http:/map.bing.com 我希望运行后批处理文件在以下标题中显示链接,如下所示: ▬ Google.com ▬ h
http://drive.google.com
http://gallery.bing.com
http://mail.yahoo.com
http://video.google.com
http://brb.yahoo.com
http:/map.bing.com
我希望运行后批处理文件在以下标题中显示链接,如下所示:
▬ Google.com ▬
http://drive.google.com
http://video.google.com
▬ Yahoo.com ▬
http://mail.yahoo.com
http://brb.yahoo.com
▬ Bing.com ▬
http://gallery.bing.com
http:/map.bing.com
下面的示例脚本怎么样 流量:
表示当一行(如果不是“!val:google.com=!”=“!val!”
)包含val
时,将运行set命令google.com
google.com
、yahoo.com
和bing.com
的情况。因此,如果存在http://google.com.yahoo.com
,结果同时显示在google.com
和yahoo.com
上link.txt
将被结果覆盖。因此,请小心。如果要将结果添加到link.txt
,请从echo-Google.com->%outputfile%
更改为echo-Google.com->%outputfile%
发件人:
致:
下面的示例脚本怎么样 流量:
表示当一行(如果不是“!val:google.com=!”=“!val!”
)包含val
时,将运行set命令google.com
google.com
、yahoo.com
和bing.com
的情况。因此,如果存在http://google.com.yahoo.com
,结果同时显示在google.com
和yahoo.com
上link.txt
将被结果覆盖。因此,请小心。如果要将结果添加到link.txt
,请从echo-Google.com->%outputfile%
更改为echo-Google.com->%outputfile%
发件人:
致:
这个简单的批处理文件不需要显式地写入目标站点;它使用与示例数据格式相同的文件中的任何URL 结果:
- bing.com -
http://gallery.bing.com
http:/map.bing.com
- google.com -
http://drive.google.com
http://video.google.com
- yahoo.com -
http://mail.yahoo.com
http://brb.yahoo.com
这个简单的批处理文件不需要显式地写入目标站点;它使用与示例数据格式相同的文件中的任何URL 结果:
- bing.com -
http://gallery.bing.com
http:/map.bing.com
- google.com -
http://drive.google.com
http://video.google.com
- yahoo.com -
http://mail.yahoo.com
http://brb.yahoo.com
但结果未保存在link.txt中。我运行批处理文件,但没有看到Result@moh3en很抱歉给您带来不便。我更新了我的答案。请确认。@moh3en也谢谢。但结果不保存在link.txt中。我运行批处理文件,但没有看到Result@moh3en很抱歉给您带来不便。我更新了我的答案。请确认。@moh3en也谢谢你。
echo - Google.com -
for /L %%i in (0,1,!g!) do echo !google[%%i]!
echo.
echo - Yahoo.com -
for /L %%i in (0,1,!y!) do echo !yahoo[%%i]!
echo.
echo - Bing.com -
for /L %%i in (0,1,!b!) do echo !bing[%%i]!
set outputfile=link.txt
echo - Google.com - > %outputfile%
for /L %%i in (0,1,!g!) do echo !google[%%i]! >> %outputfile%
echo. >> %outputfile%
echo - Yahoo.com - >> %outputfile%
for /L %%i in (0,1,!y!) do echo !yahoo[%%i]! >> %outputfile%
echo. >> %outputfile%
echo - Bing.com - >> %outputfile%
for /L %%i in (0,1,!b!) do echo !bing[%%i]! >> %outputfile%
@echo off
setlocal EnableDelayedExpansion
rem Sort and store urls
for /F "tokens=1* delims=." %%a in (link.txt) do (
set "name[%%b]=!name[%%b]! %%a.%%b"
)
rem Output sorted urls
(for /F "tokens=2* delims=[]=" %%a in ('set name[') do (
echo - %%a -
for %%c in (%%b) do echo %%c
echo/
)) > link.txt
- bing.com -
http://gallery.bing.com
http:/map.bing.com
- google.com -
http://drive.google.com
http://video.google.com
- yahoo.com -
http://mail.yahoo.com
http://brb.yahoo.com