Как сделать переименование папок правильно? А то глаз режет этот "ручной" вариант.
Спасибо
# извлекаем папку найденного файла
WhatFolder=$(dirname "${WhatFile[@]}" | sed s'/.*\/Downloads\///'g );
WhatFolder2=$(dirname "${WhatFile[@]}" );
WhatFolder_all_address=$(dirname "${WhatFile[@]}" );
RootFolder=$(dirname "$WhatFolder_all_address" | sed s'/\/\/[^/]//'g );
WhatFolder_Rename=$( echo "$WhatFolder_all_address" | sed -f "$Renamer" ) ;
WhatFolder_level_4=$( echo "$WhatFolder_all_address" | cut -d '/' -f 4 ) ;
WhatFolder_RE_level_4=$( echo "$WhatFolder_level_4" | sed -f "$Renamer") ;
WhatFolder_level_5=$( echo "$WhatFolder_all_address" | cut -d '/' -f 5 ) ;
WhatFolder_RE_level_5=$( echo "$WhatFolder_level_5" | sed -f "$Renamer") ;
WhatFolder_level_6=$( echo "$WhatFolder_all_address" | cut -d '/' -f 6 );
WhatFolder_RE_level_6=$(echo "$WhatFolder_level_6" | sed -f "$Renamer") ;
WhatFolder_level_7=$( echo "$WhatFolder_all_address" | cut -d '/' -f 7 );
WhatFolder_RE_level_7=$(echo "$WhatFolder_level_7" | sed -f "$Renamer") ;
#Massive_folder=$(echo "$("${WhatFolder2[@]}" "${WhatFolder_Rename[@]}" | tr ' ' '\n' | sort | uniq -u)");
Massive_folder=`echo ${WhatFolder2[@]} ${WhatFolder_Rename[@]} | tr ' ' '\n' | sort | uniq -u`
if [ "$Massive_folder" == "" ]
then
echo All good
else
echo Error: $Massive_folder
fi
if [[ "${WhatFolder2[@]}" != "$WhatFolder_Rename" ]] && [[ -n "$Massive_folder" ]] ;
then
if [[ -n "$Downloads"/"$WhatFolder_level_5" ]] && [[ "$WhatFolder_level_5" != "$WhatFolder_RE_level_5" ]];
then
echo "5"
mv -fv "$Downloads"/"$WhatFolder_level_5" "$Downloads"/"$WhatFolder_RE_level_5"
fi
if [[ -n "$WhatFolder_level_6" ]] && [[ "$WhatFolder_level_6" != "$WhatFolder_RE_level_6" ]];
then
echo "6"
mv -fv "$Downloads"/"$WhatFolder_level_5"/"$WhatFolder_level_6" "$Downloads"/"$WhatFolder_level_5"/"$WhatFolder_RE_level_6"
fi
if [[ -n "$WhatFolder_level_7" ]] && [[ "$WhatFolder_level_7" != "$WhatFolder_RE_level_7" ]];
then
echo "7"
mv -fv "$Downloads"/"$WhatFolder_level_5"/"$WhatFolder_level_6"/"$WhatFolder_level_7" "$Downloads"/"$WhatFolder_level_5"/"$WhatFolder_level_6"/"$WhatFolder_RE_level_7"
fi
else
echo "Нормальный формат папки"
fi