This should loop through the directory. Here is the explanation on how it works:
tokens = 1-2 means we only care about the first and second part of the file name.
delims = .
means to split the tokens on the .
in the file name.
dir /b
means to only list the files, don't show any of the .
or ..
that is normally shown in the dir
command. You need to put the directory in there or run from the same file directory.
LSS
a char
will always return GREATER THAN, that's how this works. I picked 9999, you can pick whatever.
Finally, it takes the first part of the file name (%%A
) and then the extension (%%B
) then renames to first part of the file name (%%A
) with the eps
extension.
for /f "tokens=1-2 delims=." %%A in ('dir /b') do if %%B LSS 9999 rename %%A.%%B %%A.%%B.eps
Put this in your batch file and run it.
Note: You can't rename to the same filename, so I used %%A.%%B.eps
.