自己老是下一堆书,分类是样累人的活,我很懒的<img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">
功能:根据设定的关键字用grep过滤,把匹配的文件放到各自的目录中.
@Echo OFF
::
:: BatName: Categorize.bat
:: Version: 0.1
:: Purpose: categorize for files
::
:: Usage: Categorize folderName
:: folderName target folder
::
::
:: grep.exe
::
:: Code by SpikeKnox 2007.02.08
::
SetLocal EnableDelayedExpansion
rem Show help
If == (Type "%~f0" | findstr "^::" && Goto :EOF)
If == (Type "%~f0" | findstr "^::" && Goto :EOF)
rem === ============================================================================
rem 设置类别
Set "category=csharp;sql;script;windows;unix;design"
rem 设置每个类别的关键字(传给grep用的)
Set "csharp=c\W\?sharp\|c#"
Set "sql=sql"
Set "script=script\|perl\|python"
Set "windows=windows\|office\|excel\|word"
Set "unix=unix\|linux"
Set "design=design\|设计"
rem =========================================================================================
rem Goto target folder
Pushd %1 || Pushd %~dp1
rem Build file list
Dir /b /a-d > content.txt
Echo.
Echo
Echo.
For %%I IN (%category%) DO (
Echo +
Echo.
For /F "delims=*" %%i IN ('grep -i "!%%I!" content.txt') DO (
If NOT EXIST %%I md %%I
IF EXIST %%i ( Echo %%i & Move /y "%%i" %%I\ >NUL 2>NUL )
)
Echo.
)
rem
Del content.txt
Popd
Echo.
Pause