When I run:
rename -v 's/image/img/g' *.png
It returns without changing any of the files (which are there - I checked with “ls”) and no errors reported. What could be wrong?
When I run:
rename -v 's/image/img/g' *.png
It returns without changing any of the files (which are there - I checked with “ls”) and no errors reported. What could be wrong?
Why don’t you show what the output of ls is? The usage of rename is
rename [options] *expression* *replacement* files
This will replace “expression” by “replacement.” Can you tell more about what you’re trying to do?
What you probably want, based on your regex (rename doesn’t use regexes
like that I do not think), is the following:
and that will change things like these:
‘image name here.png’
‘some dumb image.png’
imageur.png
to theseL
‘img name here.png’
‘some dumb img.png’
imgur.png
Good luck.
or you could use the mv command
On Wed, 02 Oct 2013 23:36:03 +0000, gogalthorp wrote:
> or you could use the mv command
That’s not quite as effective when it’s just a partial rename. I’m not
even sure how you’d do that without a for loop and some text processing…
Jim
–
Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C
Exactly… ‘mv’ is great at renaming one file, or moving many files to one
new directory, but it has no ability to rename many files in-place like
‘rename’ without a bunch of other hacking (loops as Jim suggests, and
probably a bit of work with variables and ‘sed’).
Good luck.
To my eye, your command only attempts to “rename” any file named g which is unlikely so of course your command fails.
You’ll probably need to add a Regular Expression wildcard if you want to rename files starting with g, or a forward slash and wildcard if the “g” is a folder name.
And, as others have noted, “rename” is not typically supported as a BASH command, you will likely want to use “mv” instead.
mv s/image/img/g/* *.png
HTH,
TSU
What he wrote is no pathname, but a sed-style replacement expression.
He wants to replace the string “image” with “img” in all *.png file names AFAIUI.
And, as others have noted, “rename” is not typically supported as a BASH command, you will likely want to use “mv” instead.
Of course “rename” is no BASH command, just like “mv” is not.
But both are standard (on openSUSE at least) LINUX commands:
# rpm -qf /usr/bin/rename
util-linux-2.21.2-10.2.1.x86_64
# rpm -qf /usr/bin/mv
coreutils-8.17-6.2.1.x86_64
@6tr6tr:
As already has been pointed out, the syntax of “rename” is:
rename [options] *expression* *replacement files*
So the correct command line for what you want to achieve would be:
rename -v image img *.png
Cool.
Yes, I just ran some testing to see how it works.
Lean something new every day.
TSU
Thank you that worked! All the examples I found online had the syntax I used. Must be the synatx for a different “rename” program?
On 2013-10-04 00:36, 6tr6tr wrote:
> Thank you that worked! All the examples I found online had the syntax I
> used. Must be the synatx for a different “rename” program?
Instead of online, you have to look at the manual page included in your
machine. Ie, “man rename”. Only then you can be sure the syntax and
examples are really for what you have.
–
Cheers / Saludos,
Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)
I did. It has no relevant examples.
Well, on my system it has (IMHO):
# man rename
...
**NAME**
rename - rename files
**SYNOPSIS**
rename [options] expression replacement file...
**DESCRIPTION**
rename will rename the specified files by replacing the first occur-
rence of expression in their name by replacement.
...
**EXAMPLES**
Given the files foo1, ..., foo9, foo10, ..., foo278, the commands
rename foo foo0 foo?
rename foo foo0 foo??
will turn them into foo001, ..., foo009, foo010, ..., foo278. And
rename .htm .html *.htm
will fix the extension of your html files.
...
On 2013-10-10 21:46, wolfi323 wrote:
>
> 6tr6tr;2590485 Wrote:
>> I did. It has no relevant examples.
> Well, on my system it has (IMHO):
Same here.
–
Cheers / Saludos,
Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))