I have many files of the form
sw001
sw002
sw003
...
I want to insert a period between the sw's and the number values. How can I accomplish this?
I have many files of the form
sw001
sw002
sw003
...
I want to insert a period between the sw's and the number values. How can I accomplish this?
If you don't have rename and don't feel like downloading it, use this:
for file in sw*; do
mv "$file" "${file/sw/sw.}"
done
On Linux:
rename 'sw' 'sw.' sw*
On Debian, Ubuntu and derivatives, use rename.ul instead of rename (rename is a different file renaming command on those distributions).
If you can can express the transformation as a Perl regular expression, rename that ships with Perl is a great choice. It applies a Perl expression to each filename, then changes the name if it is different. Often, a Perl regular expression substitution is what you want:
rename 's/sw/sw./' sw*
This is different from the rename(1) that ships with util-linux-ng, but normally the Perl version is the default. See man 1 rename to check which one your system has.