0

I try to find and move all files with the character "{" (without the quotes) for example filename{{xyz}}.txt

My Code:

@echo OFF
setlocal enableextensions disabledelayedexpansion

set "source=C:\Users\OLD\*.txt"
set "target=C:\Users\NEW"
set "searchString=}"

set "found="
for /f "delims=" %%a in ('
    findstr /m /i /l /c:"%searchString%" "%source%" 2^>nul 
') do (
    if not defined found set "found=1"
    move "%%a" "%target%"
)

if not defined found (
    echo not found
)

This script found all characters, unfortunately not that one what I need {. So now I will ask here for help.

Best regs

BASF
  • 147
  • 1
  • 3
  • 17
  • `dir /B "%source%" | findstr /m /i /l /c:"%searchString%"` to search in file _names_ – JosefZ Jun 19 '16 at 21:29
  • 1
    Why not just move them direct - `move "*{{*}}.txt" test.txt`. `*` is any or none sequence of characters. `?` is a single character. or if really only 3 characters between brackets `move "*{{???}}.txt" test.txt` –  Jun 19 '16 at 22:39
  • 1
    Are you intending to look for `}` in the file name? Or within the content of the file? Your code is looking at the file content. – dbenham Jun 19 '16 at 23:25
  • Now I use `move` like "Noodles" suggest. Thx @ all – BASF Jun 20 '16 at 20:09

0 Answers0