Computing.Net > Forums > Windows XP > XP Batch Files - Renaming

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.

XP Batch Files - Renaming

Reply to Message Icon

Name: gabson
Date: October 29, 2006 at 16:16:42 Pacific
OS: XP Pro SP2
CPU/Ram: Intel P4 2.4 GHZ 512MB
Comment:

I am trying to write a batch file that will rename a series of files within a folder. I need it to remove the first 8 characters, then add its own prefix and suffix. I don't have much experience with writing complex batch files, but here is what I've got and all it does is rename it to "prefixsuffix" with no extension. Can anyone help me out? Am I on the right track or is this even possible with this method?

for %%R in (*.*) do (
SET NAME=%%R:~8,-4%
SET EXT=%%R:~-4%
REN %%R prefix%NAME%suffix%EXT%
)

Thanks in advance!



Sponsored Link
Ads by Google

Response Number 1
Name: mattie
Date: October 29, 2006 at 16:56:21 Pacific
Reply:

belongs into the 'programming' section.

Today's subliminal thought is: 'Calm down ... it's only ones and zeros.'

icq 10183575


0

Response Number 2
Name: Mechanix2Go
Date: October 29, 2006 at 21:09:57 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for %%R in (*.*) do (
SET NAME=%%~nR
echo REN "%%R" "prefix!NAME:~8,99!.suffix"
)



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

M2



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 Windows XP Forum Home


Sponsored links

Ads by Google


Results for: XP Batch Files - Renaming

Batch file renaming question www.computing.net/answers/windows-xp/batch-file-renaming-question/111359.html

How to write XP-Batch files www.computing.net/answers/windows-xp/how-to-write-xpbatch-files/32988.html

Dos batch file rename: question. www.computing.net/answers/windows-xp/dos-batch-file-rename-question/135964.html