I am trying to rename dbf files in a folder. The batch script below is currently set up to rename the file to its current name. How do I modify the syntax to rename the files with just the first 8 characters, including the .dbf extension? I’ve tried using “%%~nx:~8.dbf” for the destination name, but it doesn’t seem to work. Thank you!
for %%x in ("C:\Users\user\Documents\monthly_adhoc\importclm\*.dbf") do (
rename "%%x" "%%~nx.dbf")
The input files would be something like this:
12345678_XXXXXXX_KKKKKK.dbf
12364178_XXXXXXX_KKKKKK.dbf
12124668_XXXXXXX_KKKKKK.dbf
12342178_XXXXXXX_KKKKKK.dbf
I’d want the output files to be this.
12345678.dbf
12364178.dbf
12124668.dbf
12342178.dbf