脚本以特殊名称索引文档

时间:2018-07-25 14:43:01

标签: batch-file solr

我目前正在使用此行将文档发送到Solr:

curl "http://localhost:8983/solr/core/update/extractliteral.id=doc1&commit=true" -F myfile=@C:\path\doc1.txt

我想编写一个脚本来浏览所有文件夹,并且仅提取文档以XX_或X_开头,并且扩展名为.html,但我不知道该怎么做

1 个答案:

答案 0 :(得分:0)

将此.bat放在您要开始搜索的根目录中。

@echo off
Echo Searching !!

setlocal enabledelayedexpansion

for /f "delims=" %%a in ('dir /a-d /b /s') do (
   if not "%%~xa"==".html" (
      set "$file=%%~nxa"
      set "$file=!$file:XX_=X_!"
      if "!$file:~0,2!"=="X_" echo File found : %%a
   )
)