批量给mac中的文件重命名bash

#!/bin/bash
i=1
for file in ~/Desktop/数据集照片/*
do
	echo "$file"
	echo "fruit$i"
	mv "$file" "~/Desktop/数据集照片/fruit$i.jpg"
	i=$[$i+1]
done;

这里的实现是将数据集照片中的所有文件重新命名为fruitxx
$file即为当前文件的名称
通过mv命令进行重命名
这里注意当要获得遍历的取值时要加$符号

你可能感兴趣的:(命令行,bash,mac)