I have compiled a batch script to amongst other things, rename a list of files, but am having problems with string manipulation within a FOR loop. At the moment it copies the name of the files into a temporary file (TempFileNames.###) and then into a FOR loop for renaming by adding the date & time. That works O.K but I'm really struggling to remove the first .csv
e.g. Test1.csv becomes Test1.csv_10052011__10_35.csv
whereas I would like it to become Test1_10052011__10_35.csv
I can strip the .csv using 'SET REMOVEFILEXT=%REMOVEFILEXT:.csv=%'
however I can't get it to work within the FOR loop, as REMOVEFILEXT remains the same and it only works for the first file.
Obviously it still works as it ends .csv but I'm trying to neaten it up.
I'm sure it's relatively easy for an expert who can point me in the right direction
DIR /B *.csv > TempFileNames.###
for /f "tokens=* delims= " %%a in (TempFileNames.###) do (
REN %%a %%a_%DATE:/=%__%TIMESTAMP:/=%.csv