Created
July 25, 2019 05:09
-
-
Save yut148/0b6fc93f8811c6f95186d4ae5c9de304 to your computer and use it in GitHub Desktop.
連番リネームする際、ファイル数の桁数を取得して桁数を揃える
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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