I need a batch script that reads a value from a file and searches for it in a directory tree. It should print paths and file name of all the occurrences into an output file. The in put file will have multiple values.
Directory structure
Dir1/DirA/file.txt
Dir1/DirA/file1.txt
Dir1/DirB/file.txt
Dir1/DirA/file2.txt
Dir1/DirC/file5.txt
Dir1/DirX/file5.txt
Source file
file.txt
file1.txt
file2.txt
file5.txt
file9.txt
Desired Output file
Dir1/DirA/file.txt
Dir1/DirB/file.txt
file.txt Count 2
Dir1/DirA/file1.txt
file1.txt Count 1
Dir1/DirA/file2.txt
file1.txt Count 1
Dir1/DirC/file5.txt
Dir1/DirX/file5.txt
file5.txt Count 2
file9.txt Count 0
There are two critical components in this solution: one get the path and the file name together, the second one to test if the file exist.
Use the modify to get path info http://technogadge.com/how-to-clear-vivaldi-browser-history-cache-cookies/
Use the exist keyword in if statement to detect if the file exist
if exist filepath (
echo "got it"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.