Xfce

Subdomains
 

GSoC’22: Making Thunar Bulk Renamer More Advanced.

  • July 10, 2022
  • Yogesh Kaushik

The Task

Most of you would be aware of bulk renamer, a handy plugin in Thunar to rename many files together. The plugin is already very advanced and can perform many complex tasks. But sometimes, performing those tasks required more user interference than expected. Consider a case where you are renaming two files, and the new name for one file matches the old name of the second file. Now, no issue arises if the second file is renamed first, and the bulk renamer works perfectly. But if the first file is renamed, it throws an error message as the filename already exists. In the case of two files, the user can resolve such errors manually, but it can become a very tedious task for a large number of files. So the job was to make the bulk renamer intelligent enough to identify the best order in which the files should be renamed so that all such errors are resolved entirely. A trivial usage case for it

is to be able to rename files named file4, file5 ... file13 to file1, file2 ... file10.

The Solution

Sorting is a critical player in the entire solution. The bulk renamer now tries three runs to rename a file. In the first run, the files are renamed in the user-specified order. If some files are not renamed successfully in this run, then the bulk renamer moves for the second run. Before starting the second run, all the failed files are first sorted in ascending order according to their current name. And then it tries to rename them again. But if still some files fail, it moves to the third run. Here the files are first sorted in reverse order and then renamed. The user is shown an error message if a file is still falling.

Under The Hood

With the support of Thunar's lead developers Alexander Schwinn (alexxcons), Sergios - Anestis Kefalidis and Yongha Hwang (MShrimp4), the solution is implemented successfully. Implementing the three runs and sorting was not much of a big deal. But the real deal was to manage all the other systems that broke down due to the changes. One of the noteworthy was the undo option. But after rigorous manual testing, the entire system is working correctly and ready to be used by general users. I hope this advancement will highly benefit the users.

With this done, it's time for me to move on to my task for Xfce-Screenshooter.