How can Bash rename a series of packages to remove their version numbers? I've been toying around with both expr
and %%
, to no avail.
Examples:
Xft2-2.1.13.pkg
becomes Xft2.pkg
jasper-1.900.1.pkg
becomes jasper.pkg
xorg-libXrandr-1.2.3.pkg
becomes xorg-libXrandr.pkg
You can press and hold the Ctrl key and then click each file to rename. Or you can choose the first file, press and hold the Shift key, and then click the last file to select a group.
To batch rename files, just select all the files you want to rename, press F2 (alternatively, right-click and select rename), then enter the name you want on the first file. Press Enter to change the names for all other selected files.
You could use bash's parameter expansion feature
for i in ./*.pkg ; do mv "$i" "${i/-[0-9.]*.pkg/.pkg}" ; done
Quotes are needed for filenames with spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With