Originally posted by Sororal at 2006-11-16 22:21:
谢谢 0451lym 兄!
没搜索到 DIRT.COM ,
给发一个好吗 Sororal@21cn.com
谢谢啦!
DIRT使用说明如下:
Dirt.COM FileName.Ext (Ver 1.15)
(|)] HH:MM:SS]
注意:本程序的设置环境变量的功能,在下面这些系统中无法正常运行。
winXP,win2000,还有在Virtual PC中虚拟的任何系统
无论是否找到符合条件的文件,Dirt.COM在退出的时候,都会设置
环境变量DirtRet:Fail表示没有找到文件,Success表示找到文件。
=====================================================
Ver 1.15
更新日期 2005-11-07
升级说明:
(1)、修正上一版本在“不带路径和文件名”搜索时直接从根目录
查找的错误。
(2)、给原先的参数YYYY-MM-DD]增加自动计算日期的功能。
例子:
Rem 找昨天修改过的所有文件
dirt *.* /d:(-2)
在最后面那个有点长的例子,因为现在增加了“自动计算日期”的功能,
所以可以简化成下面这样:
@echo off
rem ============================================
rem 这个批处理的作用是删除d:\datafile里面
rem 最后一次修改是7天之前(不包括7天)的
rem 所有文件(包括所有子目录里的文件)
rem ============================================
attrib/s d:\datafile\*.* -h -r -s
:Loop
dirt.com /d:-(-7) d:\datafile\*.* /q
if %DirtRet%==Fail goto end
del %FPath%\%FName%
goto Loop
:end
=====================================================
Ver 1.14
更新日期 2005-10-29
升级说明:
(1)、修正上一版本在根目录搜索时找不到任何文件的错误。
(2)、给的功能增加带返回码退出的功能。
这样就能在2000或xp中使用该功能。目录存在,返回1,
不存在,返回0。
例子:
判断是否存在d:\aa,如果不存在就建立,并进入
@echo off
dirt /dir:d:\aa
if errorlevel 1 goto exist
echo make d:\aa
md d:\aa
:exist
cd d:\aa
=====================================================
Ver 1.13
更新日期 2005-10-14
升级说明:
(1)、修正上一版本中对“*.*”的错误分析。
(2)、增加参数
将找到的前10个文件保存下面的环境变量中
O2E_DriverX,O2E_PathX,O2E_FNameX
分别保存盘符、路径、文件名,其中最后的X是序号,
由0至9代替,如果查找的是目录,则不会设置O2E_FNameX
(3)、增加参数
在查找到的文件或目录里,一个找出时间是最早或最晚的,
并保存下面的环境变量中,FPath,FName
furthest是查找时间是最早的文件或目录
latest则相反
(4)、增加参数
Dos系统的主环境变量列表的长度有限,因此,要学会清理垃圾。
该功能就是清除由该程序产生的所有环境变量。
(注:由该程序产生的环境变量,无法用Dos的Set命令
清除或修改,因为Set命令不支持带有小写字母的变量名)
例子:
rem 查找D:下修改时间最晚的文件,并显示出来
dirt d:\*.* /time:latest
echo %FPath%\%FName%
rem 查找D:下创建时间最早的目录,并显示出来
dirt d:\*.*\ /time:furthest
echo %FPath%
=====================================================
Ver 1.12
更新日期 2005-09-22
升级说明:
(1)、改正“搜索路径分析”中一些错误。
(2)、增加文件夹搜索的功能。支持除之外的
所有参数。
但它找的是目录的“创建时间”,跟查找文件不同(查找文件是
按文件的“修改时间”),所以当目录被改名后,它的创建时间
不会改变。
在快捷模式中,将向环境变量FPath中写入包含要搜索
的文件夹在内的全路径,而不会设置FName
用法是:在路径最后加上斜杆,具体方法看下面的例子
例子:
dirt d:\ghost8\ /q
在D盘搜索一个叫“ghost8”的文件夹,如果找到就进入
@echo off
rem 注意ghost8后面一定要加上\
rem 不然就会变成是搜索文件
dirt d:\ghost8\ /q
if == goto notexist
cd %FPath%
goto end
:notexist
echo 没有找到该目录
:end
=====================================================
Ver 1.11
更新日期 2005-09-18
新增功能介绍:
判断某个文件夹是否存在,并设置环境变量Dir:Exist表示存在,
NotExist表示不存在
例子:
判断是否存在d:\aa,如果不存在就建立,并进入
@echo off
dirt /dir:d:\aa
if == goto exist
md d:\aa
:exist
cd d:\aa
=====================================================
Ver 1.1
新增功能介绍:
无论是否找到符合条件的文件,Dirt.COM在退出的时候,都会设置
环境变量DirtRet:Fail表示没有找到文件,Success表示找到文件。
在该版本中,还修正了1.0版中参数位置不能随意改变的错误。
作用跟dir命令的/w一样,每行显示5个文件名。
开启快捷模式,只要找到有一个符合条件的文件,立即结束查找。
并且会在环境变量FPath和FName中,分别写进文件路径和文件名。
另外,该程序现在编译成.com文件,它的体积比原先的dirt.exe
小了一半。
=====================================================
例子:
找出D盘中的Tc.exe文件,如果找到就直接运行,并打开D盘
根目录下的文件try.c,如果没有找到就显示提示信息。
@echo off
Dirt d:\tc.exe /Q
if %DirtRet%==Fail goto NoFind
d:
cd %fpath%
%fname% d:\try.c
goto quit
:NoFind
echo.
echo.
echo 在D盘没有找到tc.exe
:quit
=====================================================
Ver 1.0 的功能:
YYYY-MM-DD]
指定日期,必须够位数,如:
/d:2004-05-01 不能写成 /d:2004-5-1
里面的 是只比该日期更晚或更早
如:/d:-2004-05-01 搜索2004-05-01以前的文件
HH:MM:SS]
参考日期格式
时间和日期可以一起使用
搜索子目录的最多的层数,最多为两为数(即99),
/L:0 不搜索子目录
默认为所有层
====================================================
另一个例子:
@echo off
rem ============================================
rem 这个批处理的作用是删除d:\datafile里面
rem 最后一次修改是7天之前(不包括7天)的
rem 所有文件(包括所有子目录里的文件)
rem ============================================
rem ============================================
rem 得到7天前的日期
rem 如果今天是8月25,则7天前是日期是 8月18日
rem ============================================
GetInfo.COM /d:-7
set theDay=%year%-%mon%-%day%
rem ============================================
rem 这是在D:\datafile中搜索8天前(含8天)修改过的文件
rem 即8月17日 及 之前 修改的文件
rem ============================================
attrib/s d:\datafile\*.* -h -r -s
:Loop
dirt.com /d:-%theDay% d:\datafile\*.* /q
if %DirtRet%==Fail goto end
del %FPath%\%FName%
goto Loop
:end
Originally posted by Sororal at 2006-11-16 22:21:
Thanks to brother 0451lym!
Didn't find DIRT.COM,
Can you send one? Sororal@21cn.com
Thanks!
DIRT usage instructions are as follows:
Dirt.COM FileName.Ext (Ver 1.15)
(|)] HH:MM:SS]
Note: The function of setting environment variables of this program cannot run normally in the following systems.
winXP, win2000, and any system virtualized in Virtual PC
Whether or not a file that meets the conditions is found, Dirt.COM will set the environment variable DirtRet when exiting: Fail means no file is found, and Success means a file is found.
=====================================================
Ver 1.15
Update date: 2005-11-07
Upgrade instructions:
(1) Correct the error in the previous version where it directly searched from the root directory when "without path and file name" was searched.
(2) Add the automatic date calculation function to the original parameter YYYY-MM-DD].
Example:
Rem Find all files modified yesterday
dirt *.* /d:(-2)
In the last relatively long example, because the function of "automatic date calculation" has been added now, it can be simplified as follows:
@echo off
rem ============================================
rem The function of this batch processing is to delete all files (including files in all subdirectories) in d:\datafile that were last modified 7 days ago (excluding 7 days)
rem ============================================
attrib/s d:\datafile\*.* -h -r -s
:Loop
dirt.com /d:-(-7) d:\datafile\*.* /q
if %DirtRet%==Fail goto end
del %FPath%\%FName%
goto Loop
:end
=====================================================
Ver 1.14
Update date: 2005-10-29
Upgrade instructions:
(1) Correct the error that no file was found when searching in the root directory in the previous version.
(2) Add the function of returning code exit to the function of .
In this way, this function can be used in 2000 or xp. If the directory exists, return 1,
If it does not exist, return 0.
Example:
Judge whether d:\aa exists. If it does not exist, create it and enter
@echo off
dirt /dir:d:\aa
if errorlevel 1 goto exist
echo make d:\aa
md d:\aa
:exist
cd d:\aa
=====================================================
Ver 1.13
Update date: 2005-10-14
Upgrade instructions:
(1) Correct the wrong analysis of "*.*" in the previous version.
(2) Add parameter
Save the first 10 found files in the following environment variables
O2E_DriverX, O2E_PathX, O2E_FNameX
Save the drive letter, path, and file name respectively, where the last X is the serial number,
Replaced by 0 to 9. If the searched is a directory, O2E_FNameX will not be set
(3) Add parameter
Among the found files or directories, find the one with the earliest or latest time,
And save it in the following environment variables, FPath, FName
furthest is to find the file or directory with the earliest time
latest is the opposite
(4) Add parameter
The length of the main environment variable list of the Dos system is limited, so learn to clean up garbage.
This function is to clear all environment variables generated by this program.
(Note: The environment variables generated by this program cannot be cleared or modified by the Dos Set command
Because the Set command does not support variable names with lowercase letters)
Example:
rem Find the file with the latest modification time under D: and display it
dirt d:\*.* /time:latest
echo %FPath%\%FName%
rem Find the directory with the earliest creation time under D: and display it
dirt d:\*.*\ /time:furthest
echo %FPath%
=====================================================
Ver 1.12
Update date: 2005-09-22
Upgrade instructions:
(1) Correct some errors in "search path analysis".
(2) Add the function of folder search. Support all parameters except
But it finds the "creation time" of the directory. It is different from finding files (finding files is
According to the "modification time" of the file), so when the directory is renamed, its creation time
Will not change.
In the quick mode , the full path including the folder to be searched will be written into the environment variable FPath, and FName will not be set
The usage is: add a slash at the end of the path, and the specific method is as follows
Example:
dirt d:\ghost8\ /q
Search for a folder named "ghost8" under drive D. If found, enter it
@echo off
rem Note that there must be \ after ghost8
rem Otherwise, it will become searching for files
dirt d:\ghost8\ /q
if == goto notexist
cd %FPath%
goto end
:notexist
echo No such directory found
:end
=====================================================
Ver 1.11
Update date: 2005-09-18
New function introduction:
Judge whether a certain folder exists, and set the environment variable Dir: Exist means exists,
NotExist means does not exist
Example:
Judge whether d:\aa exists. If it does not exist, create it and enter
@echo off
dirt /dir:d:\aa
if == goto exist
md d:\aa
:exist
cd d:\aa
=====================================================
Ver 1.1
New function introduction:
Whether or not a file that meets the conditions is found, Dirt.COM will set the environment variable DirtRet when exiting: Fail means no file is found, and Success means a file is found.
In this version, the error that the parameter position cannot be changed arbitrarily in version 1.0 is also corrected.
The function is the same as the /w of the dir command, and 5 file names are displayed per line.
Enable quick mode. As long as one file that meets the conditions is found, the search will end immediately.
And the file path and file name will be written into the environment variables FPath and FName respectively.
In addition, this program is now compiled into a.com file, and its volume is half smaller than the original dirt.exe.
=====================================================
Example:
Find the Tc.exe file in drive D. If found, run it directly and open the file try.c in the root directory of drive D. If not found, display a prompt message.
@echo off
Dirt d:\tc.exe /Q
if %DirtRet%==Fail goto NoFind
d:
cd %fpath%
%fname% d:\try.c
goto quit
:NoFind
echo.
echo.
echo Tc.exe not found in drive D
:quit
=====================================================
Function of Ver 1.0:
YYYY-MM-DD]
Specify the date, it must be of sufficient length, for example:
/d:2004-05-01 cannot be written as /d:2004-5-1
The inside is only later or earlier than this date
Such as: /d:-2004-05-01 Search for files before 2004-05-01
HH:MM:SS]
Reference date format
Time and date can be used together
The maximum number of layers of subdirectories to search, the maximum is two digits (that is, 99),
/L:0 does not search subdirectories
The default is all layers
====================================================
Another example:
@echo off
rem ============================================
rem The function of this batch processing is to delete all files (including files in all subdirectories) in d:\datafile that were last modified 7 days ago (excluding 7 days)
rem ============================================
rem ============================================
rem Get the date 7 days ago
rem If today is August 25, the date 7 days ago is August 18
rem ============================================
GetInfo.COM /d:-7
set theDay=%year%-%mon%-%day%
rem ============================================
rem This is to search for files modified 8 days ago (including 8 days) in D:\datafile
rem That is, files modified on August 17 and before
rem ============================================
attrib/s d:\datafile\*.* -h -r -s
:Loop
dirt.com /d:-%theDay% d:\datafile\*.* /q
if %DirtRet%==Fail goto end
del %FPath%\%FName%
goto Loop
:end