﻿<?xml version="1.0" encoding="utf-8" 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>IT博客-金鳞-文章分类-perl-File::Find</title><link>http://www.cnitblog.com/chenxin9821/category/7908.html</link><description>目标-&gt;软件测试架构师</description><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 19:05:19 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 19:05:19 GMT</pubDate><ttl>60</ttl><item><title>获取当前目录下的所有文件列表及目录</title><link>http://www.cnitblog.com/chenxin9821/articles/52693.html</link><dc:creator>金鳞</dc:creator><author>金鳞</author><pubDate>Tue, 16 Dec 2008 14:47:00 GMT</pubDate><guid>http://www.cnitblog.com/chenxin9821/articles/52693.html</guid><wfw:comment>http://www.cnitblog.com/chenxin9821/comments/52693.html</wfw:comment><comments>http://www.cnitblog.com/chenxin9821/articles/52693.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenxin9821/comments/commentRss/52693.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenxin9821/services/trackbacks/52693.html</trackback:ping><description><![CDATA[<br><span style="FONT-FAMILY: Courier">@rem = '--*-Perl-*--<br>@echo off<br>if "%OS%" == "Windows_NT" goto WinNT<br>perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9<br>goto endofperl<br>:WinNT<br>perl -x -S %0 %*<br>if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl<br>if %errorlevel% == 9009 echo You do not have Perl in your PATH.<br>if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2&gt;nul<br>goto endofperl<br>@rem ';<br>#!/usr/local/bin/perl -w<br>#line 15<br>use strict;<br>use File::Find; <br>my $path = "."; <br>find(\&amp;process, $path); <br>sub process<br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $dir = $File::Find::dir;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $dir =~ s/^\.\///; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $dir =~ s/\//\\/g;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "'$_' is in the directory of".$dir."</span><a href="file://%22.$_,%22/n">\\".$_,"\n</a>"; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>exit 0; <br>__END__<br>:endofperl<br><br><br>1 复制上述代码，存储到一个新批处理文件中，如rlist.bat<br>2 把rlist.bat拷备到需要列出所有文件的目录下<br>3 通过命令行窗口执行rlist.bat &gt; flist.txt，文件列表就会存储到重定向文件flist.txt中<br><br>感谢那个哥们的blog，嘿嘿！ 
<img src ="http://www.cnitblog.com/chenxin9821/aggbug/52693.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenxin9821/" target="_blank">金鳞</a> 2008-12-16 22:47 <a href="http://www.cnitblog.com/chenxin9821/articles/52693.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>