We have already discussed the question of sorting files of different types with help of batch scripts. But what's about sorting text files by their contents? This task is also quite simple and can be done in a few lines of code. Of course, it becomes even simpler if you use Dr.Batcher to create batch scripts.
So here is the example that can be used in sorting LOGs of different applications or downloaded files, or in other suitable cases. The script searches for the given phrase in all text files placed in the current folder, and if the phrase is found, the file that contains it is replaced to the specified folder.
@echo off
for %%i in (*.txt) do (
find "first phrase" "%%i" > nul && MOVE "%%i" 1
find "second phrase" "%%i" > nul && MOVE "%%i" 2
rem Add here your phrases.
)
Hope this script will be useful for you.
Tuesday, February 1, 2011
How to Sort Out Files of Differnet Types with Help of Batch Files, Chapter II: Sorting Text Files by Their Contents
Labels:
batch files,
scripts,
sorting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment