1

I have multiple files with dates on them I would like to strip.

exOpTimer01232018.txt

exOpProcess01232018.txt

exOpFac01232018.txt

exOpProd01232018.txt

I would like to have a batch script remove the date and leave result such as

exOpTimer.txt

exOpProcess.txt

exOpFac.txt

exOpProd.txt

These are monthly file and the date stamp changes every month.

I have tried doing

RENAME C:\temp\*????????.txt *.txt

But wasn't successful.

Community
  • 1
  • 1
MakkaCha
  • 35
  • 8
  • Use a loop to set each files name, _(without extension)_, to a variable then remove the last eight characters from that variable before appending the files extension. – Compo Jan 23 '18 at 19:17

1 Answers1

2

Example based on my comment:

@Echo Off
For /F "Delims=" %%A In ('Where .:exOp*.txt 2^>Nul') Do Call :Loop "%%A"
Pause
Exit

:Loop
Set "fName=%~n1"
Ren %1 "%fName:~,-8%%~x1"
Compo
  • 36,585
  • 5
  • 27
  • 39