I have list of folder names file1xxxfile2xxxfile3xxxI want to remove xxx from it's name.I tried the following bashfor dirname in $(cat ${in}/all.txt); do # all.txt include the name of the folders in specific path ${in}    [ -d $dirname ] || continue    mv ${in}/$dirname ${in}/${dirname//.nii/}donebut it didn't work!any suggestions?
How can I remove part of folder name
bash
In bash you can do :while IFS= read -r dir; do [[ -d $dir ]] && mv -i $dir ${dir%???}; done <all.txtthis will read the file all.txt line by line and check if the directory represented by the line exists, if so then renaming will be done accordingly.EDIT :To remove only one character, make the parameter expansion pattern ${dir%???} as ${dir%?}, the metacharacter ? represents single character in bash. So :while IFS= read -r dir; do [[ -d $dir ]] && mv -i $dir ${dir%?}; done <all.txt