First of all, there is a very useful refrencial site that you can use to query some information about cmd syntax and some tips. the site is ss64.com;
There is a interesting discussion on how to use the cmd to parse text from a file into array and process the array one by one, also he wants to fetch each of the elements individually.
The discussion is in this page: .bat script for creating Array from txt file.
to parse a record (separated by ., and we want to retrieve the 1,2,3 elemetns), here is the code that you can write.
for /F "tokens=1,2,3* delims=." %%x in ('echo 2012.249.0.0') do echo %%x.%%y.%%z
the output would be
2012.249.0
and if you want to enter an line of text into an array, by loop through the file, you can do this:
setlocal EnableDelayedExpansion
set i=0
for /F "delims=. tokens=1,2,3*" %%a in ('echo 2012.249.0.0') do (
set /A i+=1
set array[!i!]=%%a.%%b.%%c
)
set n=%i%
Once you have the array, you can loop through the array with this methods.
for /l %%a in (1,1,%n%) do echo !array[%%a]!
to make an subroutine, you can do this:
:theSub arrayName arrayLen
for /L %%i in (1,1,%2) do echo !%1[%%i]!
exit /B
:next
call :theSub array %n%
the whole demo files is available hrere:
REM http://stackoverflow.com/questions/9448651/bat-script-for-creating-array-from-txt-file
REM
REM array_fields.bat
REM this script demonstrate how to parse a text file line by line to an array and fetch the element each individually
REM
for /F "tokens=1,2,3* delims=." %%x in ('echo 2012.249.0.0') do echo %%x.%%y.%%z
REM output 2012.249.0
setlocal EnableDelayedExpansion
set i=0
for /F "delims=. tokens=1,2,3*" %%a in ('echo 2012.249.0.0') do (
set /A i+=1
set array[!i!]=%%a.%%b.%%c
)
set n=%i%
REM to prin the array elements
for /l %%a in (1,1,%n%) do echo !array[%%a]!
goto :next
:theSub arrayName arrayLen
for /L %%i in (1,1,%2) do echo !%1[%%i]!
exit /B
:next
call :theSub array %n%
endlocal
分享到:
相关推荐
Pandas-and-NumPy-Tips-Trick-and-Techniques-master
在VB6(Visual Basic 6)中,"S-a-D-trick.rar_Join In" 这个主题涉及到的是文件分割与合并的技术。在处理大文件时,为了方便传输或者存储,我们可能会选择将其分割成多个小文件,而在需要使用整个文件时,则需要将...
Python-trick,上传的事pdf文档
在规定的时间内,使用鼠标控制帽子接住落下的保龄球,躲避炸弹。_Hat-Trick
【HLP-Trick-crx插件】是一款专为解决特定网页限制而设计的浏览器扩展程序,主要用于恢复用户在浏览网页时被禁用的复制、粘贴功能,以及上下文菜单和本地高亮显示功能。这款插件特别适用于那些因为版权保护或者安全...
语言:python 内容包括:源码、数据集、数据集描述、论文 目的:使用CNN算法在橄榄球比赛中目标检测。 带数据集很好运行,主页有搭建环境过程。主页有更多源码。 数据集描述如下: 在这场比赛中,你的任务是预测球员...
我以前开发产品的动态域名解析 非常稳定 /* * ez-ipupdate * * a very simple dynDNS client for ... * I don't like to see UNIX get the short end of the stick. * * tested under Linux and Solaris. * */
gtg-grind-trick-generator PWA Web应用程序(Node.js,JS,HTML,CSS) Chrome,Safari,Firefox,Edge(Android,iOS,MacOS,Windows) 离线工作Android应用程式使用Google Workbox,Webpack制作
An Internet Exchange Points (IXP) (typically in a standalone building with its own switches) is a meeting point where multiple ISPs can connect and/or peer together. An ISP earns its money by ...
Python 提示和技巧 ... git clone https://github.com/plasmashadow/py-trick-book.git 我假设您安装了 ipython 导航到目录并执行 ipython notebook 笔记: 退出间谍活动并自己阅读 或者 保持冷静,加入草帽海贼团
1. 下载最新版本的源代码,例如压缩包内的hattrick-0.1.6。 2. 在VDR环境中编译和安装插件。这可能需要熟悉Linux环境和基本的编译命令。 3. 配置VDR以启用Hattrick插件,并设置与Hattrick账户的连接信息。 4. 更新...
...DOCTYPE>声明、元素、元素和元素。<!...包含元数据,如标题()、字符集(<meta charset="UTF-8">)和链接外部资源(如CSS文件)。则包含网页的可见内容,如文本、图像、链接等。...例如,使用和来定义页面头部和底部,...
React 21 卡技巧一个演示卡片技巧的React应用程序。动机该项目旨在学习如何使用 React 钩子和进行嵌套的 api 调用。 该项目不再进行。怎么玩记住 21 张卡片中的 1 张后,单击完成。 选择您的卡片所在的 3 堆中的哪一...
Trick-CMCC 利用CMCC公共热点的小漏洞免费上网~~ :) sudo ./conn.sh Notice: 目前只知道我工CMCC有这特色, 其他地区尚不明确 Notice: 脚本适用于使用NetWorkManager网络sds管理工具的系统 Notice: 不必惊讶原理, ...
Go in Practice guides you through 70 real-world techniques in key areas like package management, microservice communication, and more. Following a cookbook-style Problem/Solution/Discussion format, ...
该扩展程序重新启用网页上的复制/粘贴功能,上下文菜单和本机突出显示功能。 支持语言:English (United States)
10. Continued reversing techniques in VB, use of decompilers and a basic anti-anti-trick 11. Intermediate patching using Olly's "pane window" 12. Guiding a program by multiple patching. 13. The use ...
在机器学习中,核技巧(Kernel Trick)是一种非常重要的技术,它允许我们在高维特征空间中有效地进行线性学习算法的操作,而无需显式地计算出高维空间的数据表示。核技巧在诸如支持向量机(SVM)等算法中发挥了重要...
"Trick"这一主题似乎与一套特别的字体资源相关,其中包括多种不同风格的图像文件(.gif)和TrueType字体文件(.TTF)。让我们深入探讨一下这个话题。 首先,.gif 文件是一种常见的图像格式,支持透明度和动画,常...