On Mon, 16 Jan 2023 20:08:39 -0600 "David C. Rankin" <drankinatty@suddenlinkmail.com> wrote:
On 1/16/23 18:29, David C. Rankin wrote:
On 1/16/23 02:07, Simon Becherer wrote:
i have to rename hunderts of files: 792041_100029699.mi 792090_100029501.mi . . . to 792041.mi 792090.mi . . .
cd /path/to/dir/with/files
for fname in *; do [ -f "$fname" ] || continue # skip everything not a file mv "$fname" "${fname%_*}.mi" done
(will work for any advanced or POSIX shell, ash, bash, dash, etc...)
Another option for REGEX replacement is the gprename package in the main repo. Only issue is the interface looks terrible with the "courier new" font that is hardcoded. It's just a perl script, so you can change line 69 to:
style 'my_text' { font_name ='DejaVu Sans Mono' }
to use DejaVu Sans Mono as the font and it looks 100 times better.
I've searched the repos for 15.4 and cannot find a perl-rename package for openSUSE. Perl-rename (packaged as rename on many distros) is so much more flexible than the rename (from the util-linux package) used by openSUSE, there is really no comparison.
Why is everybody suggesting variations on scripts and other commands, when the command that Simon used will do the job he requires and even has an exact example of how to do it on its man page?