Need to move all files from one directory that match the format below to another directory *-*-*.pdf where * must be numeric
::====== begin batch
@for /f %%a in ('dir /b \xxx\*-*-*.pdf | findstr /r "[0-9]*-[0-9]*-[0-9]"') do @echo move \xxx\%%a elsewhere
::====== end batch
this will however, pick up files with null between dashes: --999 -8-99 in some cases. Further refinement might be required in the filtering...
Take out the echo when you feel brave and confident..
This helps but is moving items I wouldn't expect it to move. I'm testing with 2 files 123-4569-123.pdf and 123-G4569-123.pdf. It moves both of them when I would expect the one with a letter G to not move as it isn't numeric.
I think I figured it out for /f %%a in ('dir /b *-*-*.pdf ^| findstr /r "[0-9]*-[0-9]*-[0-9]"') do move /y %%a elsewhere
I needed a ^ for this to work in my batch code Thank you so much for your help!!!!
my mistake too late in posting edited
My mistake most for getting it wrong. I had it right in my "working model", but I must have hand-typed instead of cut/paste to the forum, and in so doing lost the carat (or easter-bunny made early appearance and stole it). "good eye" for catching my goof, glad you got it working.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |