<?xml version="1.0" standalone="yes"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>慢点博客 - ◎批处理技术</title><link>http://vanidea.com/blog/</link><description>人生在世，无非是让别人笑笑，偶尔笑笑别人；一个个人知识管理BLOG。 - </description><generator>RainbowSoft Studio Z-Blog 2.2 Prism Build 140101</generator><language>zh-CN</language><copyright>Copyright VanIdea.Com Some Rights Reserved. 浙ICP备05049904号||var _bdhmProtocol = ((&amp;quot;https:&amp;quot; == document.location.protocol) ? &amp;quot; https://&amp;quot; : &amp;quot; http://&amp;quot;);document.write(unescape(&amp;quot;%3Cscript src='&amp;quot; + _bdhmProtocol + &amp;quot;hm.baidu.com/h.js%3F80a2378bab8e2038132388e4fa3519be' type='text/javascript'%3E%3C/script%3E&amp;quot;));||</copyright><pubDate>Tue, 09 Jun 2026 13:27:16 +0800</pubDate><item><title>在WINDOWS7中如何进行IP地址切换（批处理） </title><author>vanidea@qq.com (慢一点)</author><link>http://vanidea.com/blog/post/523.html</link><pubDate>Thu, 06 Dec 2012 17:25:19 +0800</pubDate><guid>http://vanidea.com/blog/post/523.html</guid><description><![CDATA[<p>　　假如你的笔记本需要在家里和公司频繁地进行IP地址切换，是不是很烦？而网上大量的切换工具对Win7均无效，怎么办？请不要担心，自己DIY一个批处理文件就行了。</p><p>　　注意，以下是针对IPv4进行的修改。</p><p>　　另外，安装了360可能会有风险提醒，请大家不要担心，放心点击通过，此代码毫无风险，童叟无欺，尽可安全使用。</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　首先，打开记事本，新建一个&quot;IP切换.txt&quot;，内容如下，</span>  <span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">最后，把文件名改为&quot;IP切换.bat&quot;就大功告成了。</span> </span></p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>@echo  off</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem //设置变量本地连接, 根据你的需要更改</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Nic=&quot;本地连接 3&quot;</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem //可以根据你的需要更改</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Addr=192.168.1.11//改成自己公司的IP</p><div><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Mask=255.255.255.0//改成自己公司的子网掩码</div><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Gway=192.168.1.1//改成自己公司的网关</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Dns=192.168.1.1</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Addr2=10.32.66.34//改成自己家的IP</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Mask2=255.255.255.192//改成自己家的子网掩码</p><div><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Gway2=10.32.66.62//改成自己家的网关</div><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Dns1=202.107.196.144</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set Dns2=202.101.172.46</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem //以上对应分别是IP地址、子网掩码、网关、首选DNS、备用DNS ，自己根据情况修改</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem //家里的DNS和公司一样则可以用以上代码，不一样可能需要稍作修改</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ★ 1 设置为公司IP ★</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ★ 2 设置为居家IP★</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ★ 3 设置为动态IP ★</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ★ 4 退出          ★</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ●●●请选择项目回车●●●</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>set /p answer=</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>if %answer%==1 goto 1</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>if %answer%==2 goto 2</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>if %answer%==3 goto 3</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>if %answer%==4 goto 4</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>:1</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo 正在进行静态公司IP 设置，请稍等...</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem //可以根据你的需要更改</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. I P 地址 = %Addr%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. 子网掩码 = %Mask%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ipv4 set address name=%Nic% source=static addr=%Addr%  mask=%Mask% gateway=%Gway% gwmetric=0 &gt;nul</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. 首选 DNS = %Dns%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns%  register=PRIMARY &gt;nul</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. 备用 DNS = %Dns%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ipv4 add dns name=%Nic% addr=%Dns% index=2 &gt;nul</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ----</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo 全部设置完成!</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>pause</p><div><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>goto end</div><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>:2</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo 正在进行静态居家IP设置，请稍等...</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem //可以根据你的需要更改</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. I P 地址 = %addr2%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. 子网掩码 = %Mask2%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ipv4 set address name=%Nic% source=static addr=%addr2%  mask=%Mask2% gateway=%Gway2% gwmetric=0 &gt;nul</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. 首选 DNS = %Dns1%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns1%  register=PRIMARY &gt;nul</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. 备用 DNS = %Dns2%</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ipv4 add dns name=%Nic% addr=%Dns2% index=2 &gt;nul</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ----</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo 全部设置完成!</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>pause</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>goto end</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>:3</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo 正在进行动态IP设置，请稍等...</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. IP 地址正在从DHCP自动获取...</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ip set address %Nic% dhcp</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo. DNS地址正在从DHCP自动获取...</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>netsh interface ip set dns %Nic% dhcp</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo ----</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo 全部设置完成!</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>pause</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>:4</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>echo bye！</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>goto end</p><p><span style="color: rgb(0, 0, 0);"><span style="line-height: 20px; font-family: Tahoma; font-size: 12px; background-color: rgb(255, 255, 255);">　　</span></span>rem pause &gt;null</p><p>&nbsp;</p><p>　　资料来源：<a href="http://hi.baidu.com/coldwindsnow/item/0887e50e569c67143a53ee81">http://hi.baidu.com/coldwindsnow/item/0887e50e569c67143a53ee81</a></p>]]></description><category>◎批处理技术</category><comments>http://vanidea.com/blog/post/523.html#comment</comments><wfw:commentRss>http://vanidea.com/blog/feed.asp?cmt=523</wfw:commentRss></item><item><title>BAT批处理程序解决ARP攻击</title><author>vanidea@qq.com (慢一点)</author><link>http://vanidea.com/blog/post/406.html</link><pubDate>Fri, 22 Oct 2010 15:45:51 +0800</pubDate><guid>http://vanidea.com/blog/post/406.html</guid><description><![CDATA[<p>　　如果自己电脑遭受了ARP攻击，导致电脑上不了网，又或者在不连外网的局域网内，在没有其他软件的帮助下，能不能有自救的办法呢？其实是有的！就是用一个简单的批处理程序来解决ARP！你只需要编写它，然后运行它，保持它运行，就可以了。就是这么简单。下面来说说如何编写它。</p><p>　　首先，当然是打开&ldquo;记事本&rdquo;软件，如果你是个连&ldquo;记事本&rdquo;软件也搞不清楚的人，那就是&ldquo;右键&rdquo;-新建&ldquo;文本文档&rdquo;。然后键入以下代码。<br />&nbsp;</p><blockquote>:a<br />Arp -d<br />Ping 1.1.1.1 -n 1 -w 100<br />Goto a </blockquote><p>&nbsp;</p><p>　　接着将其&ldquo;保存为&rdquo;ArpScan.bat，然后在本机上运行。</p><p>　　双击打开，系统会弹出一个DOS窗口，此程序会一直循环下去，注意不要关闭此窗口，便可解决ARP攻击问题。</p><p>　　如果你觉得ARP清楚方法的速度太慢，可以将上面的数值100（表示0.1秒）更改为自己想设置的值。</p><p>　　这种方法的<strong>优点</strong>是让用户可以亲手解决ARP攻击问题，几乎适合任何网络环境。<strong>缺点</strong>就是使用&ldquo;Arp -d&rdquo;命令频繁地清除ARP缓存，频繁地发送ARP广播包，会使本地计算机和网络负载增加。</p>]]></description><category>◎批处理技术</category><comments>http://vanidea.com/blog/post/406.html#comment</comments><wfw:commentRss>http://vanidea.com/blog/feed.asp?cmt=406</wfw:commentRss></item><item><title>Bat批处理按指定大小分割TXT文本文档</title><author>vanidea@qq.com (慢一点)</author><link>http://vanidea.com/blog/post/381.html</link><pubDate>Mon, 27 Sep 2010 23:47:25 +0800</pubDate><guid>http://vanidea.com/blog/post/381.html</guid><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我有一个上百万级别的有效QQ号码的文档，今天突然想起来想把它分割一下，因为都被我合并了在一个TXT文本文档里。文档的体积有25M。要是经常和文档打交道的朋友知道，对于文本文档来说，25M的级别，已经后CPU卡一卡的级别了。那种服务器上一个500M的日志文件用TXT打开那就是噩梦了。我当然想到的是批处理来解决它。因为这种事情批处理是最合适的，起码我这么觉得。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当然，自己写了几个不得要领。最后还是要搜索别人的成果。当然很不错。搜索出来了。还搜索到了一个好网站，那就是<a target="_blank" href="http://www.bathome.net/">批处理之家</a>。里面很多写批处理程序的高手。获益良多。要是你也是个批处理的爱好者，这个论坛是不能错过的了。要是你有其他好的批处理资源，也希望和我分享。我把帖子中的几个办法总结了下，觉得一下两个办法比较有代表性。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>方法一：借助第三方工具</strong></p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;原理是这样的，批处理程序、第三方工具、以及要分拆的文本文档，放在同一个目录里面。第三方工具就是split.exe。<a target="_blank" href="http://unxutils.sourceforge.net/">点此下载</a>；批处理的程序代码如下：</p><p><font face="Courier New">@echo off<br />set/p file=请把要处理的文件拖到此处：<br />for /f &quot;delims=&quot; %%a in (&quot;%file:&quot;=%&quot;) do (<br />&nbsp; &nbsp;&nbsp;&nbsp;md &quot;%%~na&quot;<br />&nbsp; &nbsp;&nbsp;&nbsp;split&nbsp;&nbsp;-b 100k &quot;%file:&quot;=%&quot; &quot;%%~na\%%~na_&quot;<br />&nbsp; &nbsp;&nbsp;&nbsp;ren &quot;%%~na\*&quot; &quot;*.txt&quot;<br />)<br />pause</font></p><p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;把以上批处理程序复制成bat格式的就可以了。</font></p><p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;</font><strong><font face="Courier New">方法二：不借助第三方工具，直接批处理</font></strong></p><p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;代码如下：</font></p><p><font face="Courier New">@echo off&amp;setlocal enabledelayedexpansion<br />&nbsp; &nbsp;&nbsp;&nbsp;set/a kb+=102400,x+=1<br />&nbsp; &nbsp;&nbsp;&nbsp;set/p file=请把要处理的文件拖到此处:<br />&nbsp; &nbsp;&nbsp;&nbsp;set file=%file:&quot;=%<br />&nbsp; &nbsp;&nbsp;&nbsp;call:lp &quot;%file%&quot;<br />&nbsp; &nbsp;&nbsp;&nbsp;pause&amp;exit<br />:lp<br />md &quot;%~n1&quot;<br />for /f &quot;tokens=1* delims=:&quot; %%i in ('findstr /o &quot;.*&quot; &quot;%file%&quot;') do (<br />&nbsp; &nbsp;&nbsp;&nbsp;if %%i gtr !kb! set /a kb+=102400,x+=1<br />&nbsp; &nbsp;&nbsp;&nbsp;&gt;&gt;&quot;%~n1\%~n1_!x!%~x1&quot; echo.%%j<br />)</font></p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;直接复制成bat文件就可以使用。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;截断之后，对文档当然还是要再做校对的，那工作还是减轻了很多。对于经常看小说的朋友，或者制作TXT电子版小说的人，以上程序会有帮助。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;参考帖子：<a target="_blank" href="http://www.bathome.net/thread-2104-1-1.html">点击</a>&nbsp;<a target="_blank" href="http://bbs.bathome.net/thread-1114-1-1.html">点击2</a></p>]]></description><category>◎批处理技术</category><comments>http://vanidea.com/blog/post/381.html#comment</comments><wfw:commentRss>http://vanidea.com/blog/feed.asp?cmt=381</wfw:commentRss></item><item><title>用bat批量获取和修改文件名的方法</title><author>vanidea@qq.com (慢一点)</author><link>http://vanidea.com/blog/post/152.html</link><pubDate>Fri, 23 May 2008 18:04:41 +0800</pubDate><guid>http://vanidea.com/blog/post/152.html</guid><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 今天主任突然和我说，要把服务器上的1万多文件列个清单给他。hoho，好家伙，还被同事幸灾乐祸了。他们上星期为了3000多个文件做清单，复制粘贴了1天半，一个双休日泡汤。哈，我才没那么傻。计算机是听你指挥的。别指挥计算机做傻事情。我用以下方法，20分钟解决问题，把一个成品的EXCEL表格上交。</p><p>很简单，命令如下：<br /><br /><b>1.批量提取</b><br />新建文本文档在文本文档里输入：<br />dir *.* /a /b /s &gt;qd.txt<br />保存为 提取名字.bat<br />文件名字被提取到当前文件夹的qd.txt里面了！也可以提取某类型的文件比如*.doc 或者a*.doc<br /><span style="color: #800000">（如果装好了OFFICE软件的，直接可以创建qd.xls文件，dir *.* /a /b /s &gt;qd.xls）</span></p><p><b>2.批量重命名</b><br />新建文本文档在文本文档里输入：<br />@for /f %%a in (A.txt) do @( <br />if exist %%a for /f %%b in (B.txt) do ( <br />rename %%a %%b))<br />保存为 批量改名.bat<br />A.txt 是原来的文件名<br />B.txt 是修改后的文件名<br />一行对应一个名字不能有空格同时注意文件属性<br />a.txt :<br />NBA直播录像1.3gp<br />NBA直播录像2.3gp<br />NBA直播录像3.3gp<br />NBA直播录像4.3gp<br />b.txt :<br />NBA直播录像第一场.3gp<br />NBA直播录像第二场.3gp<br />NBA直播录像第三场.3gp<br />NBA直播录像第四场.3gp</p>]]></description><category>◎批处理技术</category><comments>http://vanidea.com/blog/post/152.html#comment</comments><wfw:commentRss>http://vanidea.com/blog/feed.asp?cmt=152</wfw:commentRss></item></channel></rss>
