How to translate file names? 论题张贴者: CafeTran Trainer
|
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 荷兰 Local time: 14:19 正式会员 (自2006) English英语译成Afrikaans南非语 + ...
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 | | |
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) English英语译成Indonesian印度尼西亚语
|
|
Samuel Murray 荷兰 Local time: 14:19 正式会员 (自2006) English英语译成Afrikaans南非语 + ...
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? | | | 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 荷兰 Local time: 14:19 正式会员 (自2006) English英语译成Afrikaans南非语 + ...
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 | | |
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 荷兰 Local time: 14:19 正式会员 (自2006) English英语译成Afrikaans南非语 + ...
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 | | |
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? Wordfast Pro | Translation Memory Software for Any Platform
Exclusive discount for ProZ.com users!
Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value
Buy now! » |
| Anycount & Translation Office 3000 | Translation Office 3000
Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.
More info » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |