How to translate file names?
Thread poster: Hans Lenting
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
Jun 29, 2023

I need to translate the names of all files in several folders:

AB123456_Machine_Installation.dxf
AB1234567_Machine_Maintenance.dxf

What is the best way to handle this? Obviously, I want to use a CAT tool for this.


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 21:49
Member (2006)
English to Afrikaans
+ ...
@Hans Jun 29, 2023

Do you just want to translate a list, or do you want to actually rename the files?

Added: If you do a search for *.* in Agent Ransack, you can copy the paths of all files.

There are DOS commands to rename files, but they all have problems (e.g. it only works in one folder, or it doesn't support Unicode characters, etc.). AutoIt's "FileMove" function typically works well -- you need to feed it to the full path of the source and target file, though.

[Edited at 2023
... See more
Do you just want to translate a list, or do you want to actually rename the files?

Added: If you do a search for *.* in Agent Ransack, you can copy the paths of all files.

There are DOS commands to rename files, but they all have problems (e.g. it only works in one folder, or it doesn't support Unicode characters, etc.). AutoIt's "FileMove" function typically works well -- you need to feed it to the full path of the source and target file, though.

[Edited at 2023-06-29 08:42 GMT]
Collapse


 
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
TOPIC STARTER
Renaming Jun 29, 2023

Samuel Murray wrote:

Do you just want to translate a list, or do you want to actually rename the files?


I actually have to rename the files.


 
Mr. Satan (X)
Mr. Satan (X)
English to Indonesian
Not something you can use with a CAT program, but… Jun 29, 2023

https://stackoverflow.com/questions/64511514/rename-translate-multiple-files-on-mac

EDIT:
I forgot to mention. Please, please, please do a dry run first in an isolated VM before even attempting to deploy it on bare metal. This should go without saying. But I suppose I'm still obliged to give a forewarning.

[Edited at 2023-06-29
... See more
https://stackoverflow.com/questions/64511514/rename-translate-multiple-files-on-mac

EDIT:
I forgot to mention. Please, please, please do a dry run first in an isolated VM before even attempting to deploy it on bare metal. This should go without saying. But I suppose I'm still obliged to give a forewarning.

[Edited at 2023-06-29 12:05 GMT]
Collapse


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 21:49
Member (2006)
English to Afrikaans
+ ...
Do you Jun 29, 2023

Hans Lenting wrote:
Samuel Murray wrote:
Do you just want to translate a list, or do you want to actually rename the files?

I actually have to rename the files.

Do you also want to rename the folders? What operating system do you use?


 
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
TOPIC STARTER
Only the files Jun 29, 2023

Samuel Murray wrote:

Do you also want to rename the folders? What operating system do you use?


For this I could use Windows


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 21:49
Member (2006)
English to Afrikaans
+ ...
Well Jun 29, 2023

Well, I would first get a list of all file paths. On my computer, I'd use Agent Ransack and do a search for *.* in the file name field. Then select all files in the list and right-click and select the option to copy paths. Then paste into a text file. E.g.

D:\DXF files\AB1234567_Machine_Maintenance.dxf
D:\DXF files\AB123456_Machine_Installation.dxf
D:\DXF files\ABCD_EFG\CD12345_Machine_Maintenance.dxf
D:\DXF files\ABCD_EFG\EF1234_Machine_Installation.dxf
... See more
Well, I would first get a list of all file paths. On my computer, I'd use Agent Ransack and do a search for *.* in the file name field. Then select all files in the list and right-click and select the option to copy paths. Then paste into a text file. E.g.

D:\DXF files\AB1234567_Machine_Maintenance.dxf
D:\DXF files\AB123456_Machine_Installation.dxf
D:\DXF files\ABCD_EFG\CD12345_Machine_Maintenance.dxf
D:\DXF files\ABCD_EFG\EF1234_Machine_Installation.dxf

Then, I would use greedy regular expressions to add a tab after the last \ character in each line, e.g.:

D:\DXF files\ [tab] AB1234567_Machine_Maintenance.dxf
D:\DXF files\ [tab] AB123456_Machine_Installation.dxf
D:\DXF files\ABCD_EFG\ [tab] CD12345_Machine_Maintenance.dxf
D:\DXF files\ABCD_EFG\ [tab] EF1234_Machine_Installation.dxf

(How regex works depends on your text program.)

Then paste everything into Excel, so that the translatable text is now all in the second column.

From here, you can mark various parts of the text as non-translatable using your CAT tool's method for doing that, e.g. mark "AB1234567" and ".dxf" as non-translatable in the first file's name. Temporarily replace underscores with spaces. Do the translation, replace spaces with underscores again, and then paste the translation back into Excel. Then copy that back into a text file, and remove tabs.

This will get you a list of translated file names and their full paths. I recommend adding a folder to the target names, e.g. change D:\ to D:\new\ so that you don't have problems with overwriting files if that happens to happen.

Then it's just a case of using a file rename utility with the original paths and the translated paths. E.g. in AutoIt, the syntax is:

FileMove ("D:\DXF files\AB1234567_Machine_Maintenance.dxf", "D:\new\DXF files\AB1234567_Ku_Hlayisa_Muchini.dxf", 9)
FileMove ("D:\DXF files\AB123456_Machine_Installation.dxf", "D:\new\DXF files\AB123456_Ku_vekiwa_ka_Muchini.dxf", 9)
FileMove ("D:\DXF files\ABCD_EFG\CD12345_Machine_Maintenance.dxf", "D:\new\DXF files\ABCD_EFG\CD12345_Ku_Hlayisa_Muchini.dxf", 9)
FileMove ("D:\DXF files\ABCD_EFG\EF1234_Machine_Installation.dxf", "D:\new\DXF files\ABCD_EFG\EF1234_Ku_vekiwa_ka_Muchini.dxf", 9)

(Since AutoIt renames using a "file move" operation, make a copy of the original files and store it in a safe place.)

[Edited at 2023-06-29 11:17 GMT]
Collapse


Hans Lenting
 
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
TOPIC STARTER
Thank you Jun 30, 2023

Thank you, Samuel. I was also thinking along those lines.

I'll try if I can come up with a script for my OS.

And I'll ask Stanislav if this task is something that he would want to add to his TransTools.


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 21:49
Member (2006)
English to Afrikaans
+ ...
@Hans Jun 30, 2023

Another (faster) option:

Once you've got the list of paths, you can use regex to turn this:
D:\DXF files\AB1234567_Machine_Maintenance.dxf
into this:
FileMove ("D:\DXF files\AB1234567_Machine_Maintenance.dxf", "D:\new\DXF files\AB1234567_Machine_Maintenance.dxf", 9)

Then load the script itself as the source file in your CAT tool, and mark everything as untranslatable except for the second instance of "AB1234567_Machine_Maintenance.dxf". Does your CAT
... See more
Another (faster) option:

Once you've got the list of paths, you can use regex to turn this:
D:\DXF files\AB1234567_Machine_Maintenance.dxf
into this:
FileMove ("D:\DXF files\AB1234567_Machine_Maintenance.dxf", "D:\new\DXF files\AB1234567_Machine_Maintenance.dxf", 9)

Then load the script itself as the source file in your CAT tool, and mark everything as untranslatable except for the second instance of "AB1234567_Machine_Maintenance.dxf". Does your CAT tool have that ability? (Or: save the script in a format that allows you to mark text as untranslatable, e.g. Microsoft Word with hidden text, and then load that into the CAT tool).

So you're essentially "translating" the script with all the commands and paths in it already. Then, when the translation is done, you save as target, and run the script immediately.

If your CAT tool can translate specific Excel columns, then instead of using untranslatable text you can add tabs like this:

FileMove ("D:\DXF files\AB1234567_Machine_Maintenance.dxf", "D:\new\DXF files\ [tab] AB1234567_Machine_Maintenance [tab] .dxf", 9)

...and load it as an Excel file in which you translate the second column into the second column. Make sure Excel doesn't break the quote characters.

Of course, whether you need to exclude the codes and/or the file extensions and convert the underscores to spaces and back, either outside or inside the CAT tool, would depend on your CAT tool's capabilities.
Collapse


Hans Lenting
 
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
TOPIC STARTER
My approach Jul 1, 2023

My approach is described here.

 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

How to translate file names?







Trados Studio 2022 Freelance
The leading translation software used by over 270,000 translators.

Designed with your feedback in mind, Trados Studio 2022 delivers an unrivalled, powerful desktop and cloud solution, empowering you to work in the most efficient and cost-effective way.

More info »
Trados Business Manager Lite
Create customer quotes and invoices from within Trados Studio

Trados Business Manager Lite helps to simplify and speed up some of the daily tasks, such as invoicing and reporting, associated with running your freelance translation business.

More info »