I have thousands of pictures in a folder like this-
1.jpg
2.jpg
3.jpg
And I want to rename them all to
1 hello.jpg
2 hello.jpg
3 hello.jpg
Try this:
#!/bin/bash
for x in [[:digit:]]*.jpg;do mv $x "${x%.jpg} hello.jpg";done
This script would be exactly doing what you want.
#!/usr/bin/env bash
for f in *.jpg
do
oldName=$(basename -s.jpg $f)
mv $f $oldName\ hello.jpg
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.