Computing.Net > Forums > Disk Operating System > deleting a character from a filenam

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

deleting a character from a filenam

Reply to Message Icon

Original Message
Name: erikals
Date: May 5, 2003 at 22:24:35 Pacific
Subject: deleting a character from a filenam
OS: WinNT
CPU/Ram: 600Mhz/256Mb
Comment:

Hi,
I'm not very good in DOS, so hope this is not a too easy question. (I'm using WinNT)

I have several file names that includes the characters [1] in them. For example,
Turtle[1].mp3
Hammer[1].mp3, and so on. Is there any way to delete those characters from the file name but still keeping the rest of the "original" name? Or do I need to do it using a batch file? I can't seem to get Dos to only delete those characters, and nothing else.

Thank you,
Erik


Report Offensive Message For Removal


Response Number 1
Name: IVO
Date: May 6, 2003 at 02:36:48 Pacific
Reply:

The following batch solves your need:

@Echo Off

:: XRen.bat Syntax: XRen [Unit:]PathName

If exist %1.\Nul GoTo EXEC
Echo.
Echo Direwctory %1 not found
GoTo EXIT

:EXEC
Dir %1 /B | Find "[1]" > %0.tmp
For /F "tokens=1,3 delims=[]" %%A in (%0.tmp) Do Ren %1\%%A[1]%%B %%A%%B

If exist %0.tmp Del %0.tmp

:EXIT

Save the batch in your root (C:) directory and run it from the Dos prompt in a Dos window (in fact in a DOS emulated machine, NTVDM under Windows NT) typing

XRen PathName of the directory where the [1] files are stored (e.g. XREN C:\MyDir\Myfiles).
Avoid names containig spaces if so get the dos format name using a dir /X command.
Repeat the process in each directory where there are files to be renamed.
Good work


Report Offensive Follow Up For Removal

Response Number 2
Name: erikals
Date: May 6, 2003 at 06:58:20 Pacific
Reply:

:D

Your'e the man!
It works great, thank your very much.

Arigato,
Erik


Report Offensive Follow Up For Removal







Post Locked

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


Go to Disk Operating System Forum Home



Results for: deleting a character from a filenam

how do ik set up a network from a laptop
    Summary: how do ik set up a network from a laptop that can only boot to a dos prompt to a desktop runnning win 2000 i've had answers to some of my quesstions, but the main one how do i create a network from a...
www.computing.net/answers/dos/how-do-ik-set-up-a-network-from-a-laptop/6440.html

removing section from filenames
    Summary: In your examples, you didn't mentioned any filename with spaces, so I didn't consider the possibility, sorry. Yes, it's possible. However, it will complicate things. It's better if you state your OS (...
www.computing.net/answers/dos/removing-section-from-filenames/10716.html

Create a filename with a timestamp
    Summary: I would like to create or rename a file in DOS. I need to programmatically change the filename so I thought that having a timestamp as the name would be an easy way to keep track of the file. Is the...
www.computing.net/answers/dos/create-a-filename-with-a-timestamp-/12377.html






Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History






Data Recovery Software