Computing.Net > Forums > Programming > Advance rename

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Advance rename

Reply to Message Icon

Name: dveerl
Date: February 10, 2006 at 22:05:22 Pacific
OS: win xp
CPU/Ram: pen4 512g
Product: intel
Comment:

Hi
I would like to write a batch file using rename - i need to schedule it ....
I have a list of files in a dir
My files do not have extension
For example ABCDEFGHIJKL
And I would like to change it to
DIR-ABCDEFGHIJ.SLOT

1. Evrey file will start with DIR-
2. The last two letters of the file will be trimmed
3. File extension will be renamed to .SLOT

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: shahramsh
Date: February 11, 2006 at 11:01:15 Pacific
Reply:

this should do it:

give the path to the batch file as %1

@echo off
set bn=%0
if "%1"==":trim" goto trim
if "%1"==":dir" goto dir
for /r %1 %%I in (*.*) do call %bn% :trim %%I %%~nI
for /r %1 %%I in (*.*) do call %bn% :dir %%I %%~nI
ren %1\* *.slot
goto EOF
:trim
set x=%3
set x1=%2
set x2=%x:~0,-2%
ren "%x1%" "%x2%"
goto EOF
:dir
set x=%3
set x1=%2
set x2=DIR-%x%
ren "%x1%" "%x2%"
:EOF



0

Response Number 2
Name: dveerl
Date: February 19, 2006 at 03:11:52 Pacific
Reply:

thnaks

for your help


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Advance rename

batch for renaming www.computing.net/answers/programming/batch-for-renaming/14941.html

Renaming problem www.computing.net/answers/programming/renaming-problem/15535.html

Batch file for renaming folders www.computing.net/answers/programming/batch-file-for-renaming-folders/15430.html