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.
read
a file? What is thedone < read
reading from? Also, what operating system are you using? Different systems have different tools available.test untitled wis
ortest untitledfolder wis
.my.custom.name1
andmy.custom.name2
?echo
is a POSIX command, its behaviour is left mostly unspecified and in practice it's not portable.read
is also a POSIX command, but you're using it improperly here if the intent is to read a line from a file.