Computing.Net > Forums > Programming > Files rename using batch file

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.

Files rename using batch file

Reply to Message Icon

Name: Egy
Date: February 19, 2008 at 07:24:12 Pacific
OS: XP
CPU/Ram: pentuim
Product: 123456789
Comment:

I would like to rename numbers of files as following:
from test1.test1.txt --TO-- test1.test1-abc.txt

I used this line
for /f %%i in ('dir /b /a-d *.pst') do @ren %%i %%i.pst
but it does not work !!
How can I rename this files name using bactch file?
Thank you,



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: February 19, 2008 at 08:26:23 Pacific
Reply:

for %%i in (*.pst) do ren %%i %%~ni-abc.%%~xi

(P.S. If you are testing this interactively on the command line, just use a single % instead of %%.)


0

Response Number 2
Name: Egy
Date: February 19, 2008 at 09:09:25 Pacific
Reply:

it works fine, but it added (..) then the extention. how I can get rid of the senc (.)



0

Response Number 3
Name: Egy
Date: February 19, 2008 at 09:13:35 Pacific
Reply:

I got it,

thanks


0

Response Number 4
Name: klint
Date: February 19, 2008 at 09:16:47 Pacific
Reply:

Sorry about that, here's the corrected version:

for %%i in (*.pst) do ren %%i %%~ni-abc%%~xi

(My previous version had an extra . which was not required because %%~xi itself contains the dot as part of the extension.)


0

Response Number 5
Name: Egy
Date: February 19, 2008 at 10:44:07 Pacific
Reply:

thank for your help


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






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: Files rename using batch file

Telnet using Batch file www.computing.net/answers/programming/telnet-using-batch-file/12716.html

Merging text files using batch file www.computing.net/answers/programming/merging-text-files-using-batch-file/19906.html

Batch file to rename a file www.computing.net/answers/programming/batch-file-to-rename-a-file/14356.html