Forum: CAT Tools Technical Help
Topic: How to translate file names?
Poster: Samuel Murray
Post title: Well
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]
Topic: How to translate file names?
Poster: Samuel Murray
Post title: Well
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]