Computing.Net > Forums > Programming > Batch File --- need help

Batch File --- need help

Reply to Message Icon

Original Message
Name: litak
Date: November 1, 2007 at 22:07:22 Pacific
Subject: Batch File --- need help
OS: Windows XP
CPU/Ram: 1GB
Model/Manufacturer: intel
Comment:

Hi All,
I am new in writing windows batch file. I am facing a problem and not able to solve it, so please help me out. My problem is ---

I need to rename all files of the form *.mp4.ts in an input folder to only *.ts. i.e. if the file name is "a.mp4.ts" after renaming it will be "a.ts" in the same folder. Batch file will take only the input folder as an input.

Thanks in advance...

regards
litak


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: November 2, 2007 at 00:52:10 Pacific
Subject: Batch File --- need help
Reply: (edit)

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d *.mp4.ts') do (
set name=%%~Na
set name=!name:~0,-4!
echo ren %%a !name!.ts
)



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: litak
Date: November 2, 2007 at 05:05:00 Pacific
Subject: Batch File --- need help
Reply: (edit)

Thanks for the reply...
In the mean time I made another solution...

FOR %%i IN (*.*.ts) DO (FOR %%j IN (%%~ni) DO (REN %%i %%~nj.ts))

and it works for me... !!!

Anyway thanks for the help...

litak


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch File --- need help

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge