Rename - Replace a Char with another in all file/Dir _names_

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Rename - Replace a Char with another in all file/Dir _names_

Post by *eitang »

Hi,

This is not really a TC question/problem but it is related:

I needed to change all accented characters in file names and directory names. (Using two incompatible languages PC's with an external USB disk). For example, change all occurences of é with e, of à with a, etc. in a full directory structure.

I used TC's _excellent_ FIND *é*.*, COPY to listBox, and renamed each file. This is a hell of a job. It made me think of writing a text editor that will read into itself all such files/directories, do the replace and then proceed to the actual rename.

This was too much work and I did the thing (manual rename) in about an hour using SHIFT-F6.

Does such an "editor" exist?

Anybody has a better idea on how to do that?

TIA,

EitanG
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2eitang
Anybody has a better idea on how to do that?
1. Search for *é* *à* and feed to listbox.
2. Select dirs/files to rename.
3. Call the Multi Rename tool (Files/Multi Rename tool, Ctrl+M)
4. type é in "Search for" and e in "Replace with".
5. Start!

There is currently no way to replace multiple strings at once. You'll have to repeat the procedure to replace all accented characters.
This will be possible in the next version:
Search for: é|à
Replace with: e|a
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Re: Rename - Replace a Char with another in all file/Dir _na

Post by *Sheepdog »

eitang wrote: change all occurences of é with e, of à with a, etc. in a full directory structure.
There is a little tool renamer what shall do the work for you.

bkren -s "(.*)é(.*)" "\1e\2"
bkren -s "(.*)É(.*)" "\1E\2"
bkren -s "(.*)à(.*)" "\1a\2"
bkren -s "(.*)À(.*)" "\1A\2"

Put this code into a batch-file and execute it in the desired drirectory. The "-s" switch includes the subdirectories.

ATTENTION: You have to make sure to use DOS-charset (not windows). Otherwise you wll get strange results. Easiest way I think is to use the DOS editor (you get on the console with typing edit).
Anyway - you should make some tests first in a test folder.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Sheepdog

Thanks for BKREN ! It does the job beautifully.

Lefteous,

Thank you, I hadn't noticed the "replace" option in Multi-Rename! You always learn something nez with TC (I've been using it for many years),

But: something is not working well with the Multi-Rename. Files "loose" their names completely, and some files do not get renamed. I don't know why.

EitanG
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

But: something is not working well with the Multi-Rename. Files "loose" their names completely, and some files do not get renamed. I don't know why.
You can always preview how the names get changed. Maybe there were conflicting names?

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

Hacker wrote:
But: something is not working well with the Multi-Rename. Files "loose" their names completely, and some files do not get renamed. I don't know why.
You can always preview how the names get changed. Maybe there were conflicting names?
Additional there is the 'undo' function. It works even if you have closed the MRT after the last action. Simply reopen it, 'undo', and all filenames are rebuilt.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
Post Reply