EvilZone
Programming and Scripting => Other => : sryker1911 February 27, 2013, 02:31:47 AM
-
Need some help coding this in BAT.
The script is written so that it does a recursive search with WMI to delete specific files on the the fixed drives.
I would like to know how to make it so that it has logic like the following, I just can't seem to figure this out in this script
IF folder above "fileName0.url" == blue && AND && fileName == fileName0.url
Then Delete file fileName0.url
else if - ignore
What I has so far, anyone have any ideas or have code to add to make it perform like the logic above
@echo off
Title Search and Delete Specific File
::Find out what disks are on the system.
for /f "usebackq skip=1 tokens=1" %%a in (`wmic logicaldisk get deviceid`) do (
::Make sure we only use the fixed disks
for /f "usebackq tokens=2 delims=:- " %%x in (`fsutil fsinfo drivetype %%a`) do (
::Is %%a, a fixed disk?
if "%%x" == "Fixed" (
echo.
echo - - - - - - - - - - - - - - - - - - - - - - - - -
echo Searching drive %%a for Startup Shortcuts
del /s/f/q "%%a\fileName0.url"
del /s/f/q "%%a\fileName1.url"
)
)
)
)
-
Look here how to get the parent directory name: http://stackoverflow.com/questions/2396003/get-parent-directory-name-for-a-particular-file-using-dos-batch-scripting
For the rest you just create an if statement with the AND operator to concatenate your conditions.
http://www.robvanderwoude.com/battech_booleanlogic.php
-
Thanks I got it working! :)