On Ubuntu. the following command needs to change the names of the folders from "n something" to "n+1 something" where n is a number that is bigger than 1.
Below is command (by openai chat) and the error:
for folder in [2-9]*; do mv "$folder" "$((10#${folder}+1))_${folder#*_}"; done
Error: -bash: 10#2 Gálatas+1: syntax error: invalid arithmetic operator (error token is "álatas+1")
Here is the output of the ls
of the parent directory with names in Spanish :
'1 Romanos' '2 G'$'\303\241''latas' '3 Hebreos' '4 Santiago' '5 I Pedro' '6 II Pedro' '7 Judas' '8 Apocal'$'\303\255''psis'
How can this be done without having to manually mv
every directory? Thanks
Assuming you don't have folder names with multiple consecutive spaces, you can try this :
for folder in [2-9]*; do
read -r number rest <<< "$folder"
echo mv "$folder" "$((number + 1)) $rest"
done
remove echo
when you are ready to run mv
.