0

I use the script from this Thread accepted answer from Mofi. The script copy folders and store them in text file to exclude once copied folders on next run.

Sometimes I have folders called [incomplete]-different.names and I do not want to copy this folders. I want that all folders with the string [incomplete]- and the name behind are skipped or are not even written in the text file %CurrentList% for further processing.

These are my previous attempts but so far I could not get up and running with the script from the top. Help would be nice, and thanks in advance.

Try 1:

for /f "delims=" [incomplete]-%%D in ("%CurrentList%") do ( set str=%%D set str=!str: =! set str=!str: %%D =! echo !str!

Try 2:

findstr /v /b /c:"[incomplete]-"%%D" "%CurrentList%" del "%%D"

Community
  • 1
  • 1
BASF
  • 147
  • 1
  • 3
  • 17
  • `findstr` uses regular expressions and `[` and `]` are regular expression characters. Without seeing examples of what you are trying to filter out then we don't know what characters need to be handled. Alternatively, `find.exe` is a simpler filter. But without accurate information you will often not get good advice. – foxidrive Sep 26 '15 at 03:25

1 Answers1

0

You were really close with your second attempt.

If all you want is to delete lines in %CurrentList% that contain the string [incomplete]-, you can just direct the output of a findstr /v to a temp file and then overwrite CurrentList with that file.

findstr /v /c:"[incomplete]-" "%CurrentList%" >tmpList.txt
move /y tmpList.txt "%CurrentList%" >nul
SomethingDark
  • 13,229
  • 5
  • 50
  • 55