Reputation: 99
What I've managed to do so far is append it.
#!/bin/bash
for f in *
do
mv "$f" "File${f##/}"
done
File names consist of 3 random letters followed by 3 numbers. I need to replace the 3 letters with "File".
Upvotes: 0
Views: 78
Reputation: 99
Got it
#!/bin/bash
for f in *
do
newName=File"$(echo "$f" | cut -c4-)"
mv "$f" "$newName"
done
Apparently I'm not supposed to comment to say thank you so I'll just add it here. Thank you, I'll use Ignacio's method.
Upvotes: 0
Reputation: 69
You can use:
newName=`echo $f | sed 's/^[a-z]\{3\}/File/'`
mv $f $newName
Upvotes: 0
Reputation: 798606
Then you need to strip the three letters.
"File${f#???}"
Upvotes: 2