Ubuntu – Using text list to batch-rename files

batch-renamecommand line

Suppose I have a folder with some 20 files (say, photos I took on a trip), and I want to rename them in one go, only there isn't any specific Perl expression I want to use (for example, if I'd like to add additional text to each name that's not part of the individual files' meta-data, such as descriptions and/or comments).

And suppose I can more easily generate a text file with what I want each file's name to be (or, if preferable, a 'before-and-after' sort of list).

Is there any way to apply the changes implied in that text list to the folder in question?

Best Answer

This looks like a job for xargs.

If your file is formatted like this:

old_file1 new_file1
old_file2 new_file2

then you can do xargs -a your_file -n 2 mv.