Skip to content

Instantly share code, notes, and snippets.

@pcqpcq
Created February 19, 2019 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcqpcq/4471de1d55aecb057b55a11f79dde96c to your computer and use it in GitHub Desktop.
Save pcqpcq/4471de1d55aecb057b55a11f79dde96c to your computer and use it in GitHub Desktop.
demo shell script. 重命名当前目录下所有数字视频文件名
#!/bin/bash
for file in ./*
do
fname=$(basename $file .mp4) #获取文件名
expr $fname "+" 10 &> /dev/null # 判断是否数字
if [ $? -eq 0 ];then # 判断是否数字
name=$(($fname+98)) # 数字运算
echo "$name is number" # log
mv $fname.mp4 $name.mp4 # 重命名
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment