I am trying to bulk rename many folders but for some reason my approach does not seem to work. I am trying to use the following script but it does nothing. I am new to programming so any suggestions are appreciated. These are the folder names that i have.
test.custom.tmp untitledfolder.custom.tmp wis.custom.tmp
I need them renamed to
test untitledfolder wis
I am using the following script but it does nothing.
while read line; do
newname=$(echo "$line" | cut -f 1 -d '_')
mv $line newname;
done < read
Here i created a file called read with all the foldernames that need renaming.
What is wrong with this script and also is there a better way to get this done? Thanks.
reada file? What is thedone < readreading from? Also, what operating system are you using? Different systems have different tools available. – terdon May 31 '22 at 14:30test untitled wisortest untitledfolder wis. – schrodingerscatcuriosity May 31 '22 at 14:30my.custom.name1andmy.custom.name2? – Kusalananda May 31 '22 at 14:35echois a POSIX command, its behaviour is left mostly unspecified and in practice it's not portable.readis also a POSIX command, but you're using it improperly here if the intent is to read a line from a file. – Stéphane Chazelas May 31 '22 at 15:17renamefrom util-linux ormmvor similar instead...but the perl rename is the best tool for this job. – cas Jun 01 '22 at 09:35