Batch File Rename Using Mapping File

renamescripting

I have a large collection of image files, for example:

a.png, b.png, c.png, etc

If I have a file with mappings of filenames to numbers, like so (ignore the format, it could be anything):

a=>1
b=>2
c=>3
...

Is there any easy way to batch rename all the files using the mapping file to:

1.png, 2.png, 3.png, etc

I'm looking for unix/linux commands. I know I can write a very simple script, but just curious if there is any other technique.

Thanks

Best Answer

There isn't a single command for everything; that's the point of having a scriptable shell.

while read -r old new; do
    mv "$old.png" "$new.png"
done < map.txt
Related Question