这将对它:
for file in *.jpg; do
basename=${file%.*} # Get the basename without using a subprocess.
extension=${file##*.} # Get the extension if you want to add *.JPG in the for, can be skipped if only *.jpg.
newname=${basename#1234-} # Remove "1234-" in front of basename.
test "$basename" = "$newname" && # If basename did not start with "1234-", skip this file.
continue
newname=${newname%-1234} # Remove an eventual "-1234" at the end of newname.
newname="${newname}-1234" # Add "-1234" at the end of newname.
newname="$newname.$extension" # Restore extension.
echo mv "$file" "$newname" # echo rename command.
done
如果您对输出感到满意,请删除最后一行中的 echo。