mercredi 4 janvier 2017

Batch File - Search for any folder containing text, proceed when none are found

First off, i've looked around and can't seem to find something that will work for me.

What I would like to do is search a directory for any subfolder containing "NA".

Example
Folder1
Folder2
Folder3.NA

As long as there is a folder with .NA do nothing. When there is no longer any folders with .NA delete a file in a different folder.

Each time this code runs, i never get to the :NotFound section to execute deleting the file.
Maybe someone has a different solution than what i'm thinking of.

Here is my Code - this will run at startup

@echo off

setlocal enabledelayedexpansion

Set Source=C:\Temp\Users

FOR /d %%a in ("%Source%\*.NA") DO (

IF NOT !ErrorLevel! == 0 GOTO NotFound
IF !ErrorLevel! == 0 GOTO Found  REM  - There is still a user folder with .NA

)
Goto EOF

:Found
@echo There is a folder with .NA Do Nothing

Goto EOF

:NotFound
@echo Simulate delete start-up file

Goto EOF

:EOF
PAUSE

Aucun commentaire:

Enregistrer un commentaire