0

I have a batch file that I'm using to scan the c:\users folders on a Windows 7 box using a for loop. This works fine, however I am having issues in excluding certain folders.

I need to exclude the AppData folder under the users profile folders. I don't want it to use a exclude file which I have seen in other solutions.

For /R C:\USERS\ %%G IN (*.png) do "C:\program files\sdelete\sdelete.exe\sdelete.exe" -s -p 3 /accepteula "%%G"
Matt Williamson
  • 6,947
  • 1
  • 23
  • 36
User79.Net
  • 155
  • 4
  • 8
  • 18
  • 3
    Post your batch file please. – mitchimus Apr 04 '14 at 04:07
  • possible duplicate of [Batch For loop exclude file name that contains](http://stackoverflow.com/questions/16193702/batch-for-loop-exclude-file-name-that-contains) – Taylor Hx Apr 04 '14 at 04:21
  • ::For /R C:\USERS\ %%G IN (*.png) do "C:\program files\sdelete\sdelete.exe\sdelete.exe" -s -p 3 /accepteula "%%G" is what I am using at the moment. I would like to add in Gif PDF JPG extensions as well – User79.Net Apr 04 '14 at 04:40

1 Answers1

1

Test this: it should exclude \appdata\ and \folderb\

For /R C:\USERS\ %%G IN (*.png *.gif *.pdf *.jpg) do (
    echo "%%G"|find /i "\appdata\" >nul || (echo "%%G"|find /i "\folderb\" >nul) || echo "%%~dpG" remove this after testing "C:\program files\sdelete\sdelete.exe\sdelete.exe" -s -p 3 /accepteula "%%G"
)
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • It redirects normal screen text to nowhere. `Standard out` is normal screen text, and `standard error` is where error messages are sent. They both go to the console by default and are known as streams 1 and 2 respectively. You may also see terms like `2>nul` and `2>&1` to redirect error messages. – foxidrive Apr 07 '14 at 02:51