Computing.Net > Forums > Programming > Batch file for renaming files

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.

Batch file for renaming files

Reply to Message Icon

Name: Naveen
Date: June 7, 2007 at 00:53:18 Pacific
OS: Win XP
CPU/Ram: p4 1 GB
Product: Intel
Comment:

Hi,
I require a simple batch file to run on cmd prompt which when run, would do a 'dir' on the current directory/specified directory and rename the files as follows:-

existing filename format - file_[1]_name.txt
required filename format - file_name.txt

I'm not aware of the syntax for windows, so if anyone could help :-)

Thanks


Naveen



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 7, 2007 at 01:15:38 Pacific
Reply:

@echo off > file_[1]_name.txt
setLocal EnableDelayedExpansion

for /f "tokens=1-3 delims=_" %%a in ('dir/b/a-d file_*.*') do (
echo ren %%a_%%b_%%c %%a_%%c
)



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

M2



0
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: Batch file for renaming files

help on creating DOS Batch file www.computing.net/answers/programming/help-on-creating-dos-batch-file/15163.html

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

A batch file for rename www.computing.net/answers/programming/a-batch-file-for-rename/15479.html