I have a directory where users are saving their excel files that should adhere to a specific naming convention:
XX-TestFile.xlsx
where XX
is a variable digit and -TestFile.xlsx
should always be the same and not change. I'd like to be able to check through a batch job if files in the directory adhere to this naming convention.
If filename is misspelled, i.e. XX-TetsFiel.xlsx
, XX
is not a digit like 02
or even XX-testfile.xlsx
(all lowercase), then files should move to an Error directory.
I am using below to move the files to achieve this. I am testing with 11-testFiel.xlsx
but when I execute the .bat nothing happens - I get no errors and the file remains where it was before:
@echo off
for /f "delims=" %%a in ('dir /b *.xlsx | findstr /v "[0-9][0-9]-TestFile.xlsx"') do move "%%a" "C:\Temp\Archive\Error"
Many thanks in advance for your help!