|
Answer» Hello,
I’ve got a directory of files with timestamps, which I need to erase the timestamp (I will need this putting in a BATCH file as I generate over 1000 of these files a day because of a TEST driver I’m using)
Examples of these files are: 2014-01-20-Testing_1_200.txt 2014-01-20-Testing_2_400.txt 2014-01-20-Testing_3_400.txt 2014-01-20-Testing_4_200.txt 2014-01-20-Testing_5_200.txt
Can anyone specify some DOS code I can put into a batch which would get rid of the timestamp and leave the file like: Testing_1_200.txt? Erasing the timestamp?
Thanks, The Test this:
Code: [Select]@echo off for /f "delims=" %%a in ('dir *.txt /b /a-d ') do ( for /f "tokens=1,2,3,* delims=-" %%b in ("%%a") do ( ren "%%a" "%%e" ) )Hello,
Thanks for that reply,
But please could you explain how i can modify that so it will WORK with my files? I've put an example of the folder below: . 2014-20-01-Testresults_1.txt . 2014-20-01-Testresults_2.txt . 2014-20-01-Testresults_3.txt . 2014-20-01-Testresults_4.txt . 2014-20-01-Testresults_5.txt
Thanks, The code Foxidrive GAVE you should work just fine.
Code: [Select]H:\temp>dir /b *.txt 2014-20-01-Testresults_1.txt 2014-20-01-Testresults_2.txt 2014-20-01-Testresults_3.txt 2014-20-01-Testresults_4.txt 2014-20-01-Testresults_5.txt
H:\temp>Multirename.bat
H:\temp>dir /b *.txt Testresults_1.txt Testresults_2.txt Testresults_3.txt Testresults_4.txt Testresults_5.txt
H:\temp>Thanks very much - I look FORWARD to trying this out tomorrow.
I'm fairly new to DOS and working with Batch files, I look forward however to increasing my knowledge!
|