This batch code below is not an answer, just a modification to what you've posted.
@Echo Off
Set "MyTargetDir=%UserProfile%\Documents\TEMP\Junk"
Set "MySearchStrings=123 abc nyu texas"
CD /D "%MyTargetDir%" 2>Nul || Exit /B
For /F "Delims=" %%A In ('Dir /B/A-D-S-L^|FindStr /IV "%MySearchStrings%"'
) Do Echo %%A
Pause
For the remaining part of your task, you should obviously modify the Echo
command, to either Call
a label with your specific code or run command directly; using %%A
. If there are many files in the target directory, you may even want to do the last written, or date created check first. I cannot currently help you with that because you haven't attempted it yourself, (this isn't a code to order service), and you've provided insufficient information about what you mean by 10 days old.
For determining the file age I'd suggest using RoboCopy
or ForFiles
as alternatives. There are many examples of doing so on this site; please read through some answers and attempt to modify them to your specific requirements, updating your question accordingly if you do not achieve your goal.
Because you are an 'amateur' at batch files, you may be better advised to learn and use PowerShell
, which could perform this task much better, instead.
Here's a possible PowerShell example:
Get-ChildItem '$Env:UserProfile\Documents\TEMP\Junk\*.*' -Exclude *123*, *abc*, *nyu*, *texas* |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-10) } | Remove-Item -WhatIf