Created
July 15, 2024 07:35
-
-
Save MrWhiteD/f6337fb1215e83944dd402c016a75a9b to your computer and use it in GitHub Desktop.
[Переименование файлов] #rename #mv
This file contains 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
#!/bin/bash | |
cnt=$((1)) | |
listSrcFiles=$(find $orig_path$dir -maxdepth 1 -type f | grep -P -i -o "DSC\d{3,4}.jpg") | |
for file in $listSrcFiles; do | |
var=$(echo $file | grep -P -i -o "\d{3,4}") | |
var=$(($var-813)) | |
newVar=$(printf "%08d.jpg" $var) | |
echo $newVar | |
mv $file $newVar 2>/dev/null | |
cnt=$(($cnt+1)) | |
#echo $file | sed 's/DSC/00000/' | |
## удаление букв из имени файла, если есть | |
for file in $listSrcFiles; do | |
if [[ $file =~ [0-9]+[a-z].jpg ]]; then | |
newFile=$(echo $file | sed -e 's/[a-z]//') | |
#mv $orig_path$dir/$file $orig_path$dir/$newFile 2>/dev/null | |
file=$newFile | |
fi | |
done | |
done | |
echo $cnt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment