Skip to content

Instantly share code, notes, and snippets.

@yut148
Created July 25, 2019 05:09
Show Gist options
  • Save yut148/0b6fc93f8811c6f95186d4ae5c9de304 to your computer and use it in GitHub Desktop.
Save yut148/0b6fc93f8811c6f95186d4ae5c9de304 to your computer and use it in GitHub Desktop.
連番リネームする際、ファイル数の桁数を取得して桁数を揃える
https://qiita.com/catfist/items/8052e21ebfb3b7a6f9a9
@catfist
while read dir; do
num=0
cd "$dir"
for file in *; do
num="$(printf "%0${#max}d" "$((10#$num+1))")"
mv "$file" "$num-$file"
done
cd -
done < <(find . -type d -mindepth 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment