randr – Rename And Replace

randr is a command line tool that recursively searches file content for the source text and replaces it with the target text. With that, randr will also recursively rename files or folders that match the source to the target text. You can also specify a command flag to rename or replace based on case-sensitive or case-insensitive searches.

randr – Example

To illustrate the usage of randr, consider you have a project folder with the following structure:

// Project Folder: c:\Projects\Payroll\

// c:\Projects\Payroll\Models\Worker.cs
public class Worker {}

// c:\Projects\Payroll\Services\WorkerService.cs
public class WorkerService {}

// c:\{rojects\Payroll\Repositories\WorkerRepository.cs
public class WorkerRepository {}

// c:\Projects\Payroll\Helpers\Worker\Extensions.cs
public static class Extensions {}

Let’s refactor above project structure using randr and change Worker entities to Employee. randr command to refactor will look like following, which will replace any files text which contains Worker to Employee as well as will rename any file or folder with contains Worker to Employee.

randr.exe -find=Worker -replace=Employee -match=true -location=c:\Projects\Payroll\

After running randr successfully, our example project folder will look like following:

// Project Folder: c:\Projects\Payroll\

// c:\Projects\Payroll\Models\Employee.cs
public class Employee {}

// c:\Projects\Payroll\Services\EmployeeService.cs
public class EmployeeService {}

// c:\Projects\Payroll\Repositories\EmployeeRepository.cs
public class EmployeeRepository {}

// c:\Projects\Payroll\Helpers\Employee\Extensions.cs
public static class Extensions {}

Please go over README.md in the project repository for parameter usage details.

GIT Repository: