From: L A Walsh <cygwin@tlinx.org>
To: Fergus Daly <fergusd84@outlook.com>,
"cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: Has rename syntax changed?
Date: Wed, 04 Mar 2020 03:52:00 -0000 [thread overview]
Message-ID: <5E5EE76B.8000202@tlinx.org> (raw)
In-Reply-To: <AM6PR03MB5282DB8DBC61B8331D880434A4E80@AM6PR03MB5282.eurprd03.prod.outlook.com>
On 2020/02/28 04:38, Fergus Daly wrote:
> I am almost certain that the command
> $ rename "anything" "AnyThing" *.ext
> would alter the string from lc to uc as shown, anywhere it occurred in any filename in *.ext in the current directory.
>
isn't that they same as "mv anything.xxx Anything.xxx" ?
> What I remember as past behaviour now fails, leaving he filename unaltered.
>
/tmp> ll *.xxx
-rw-rw-rw-+ 1 0 Mar 3 14:30 anything.xxx
/tmp> rename any Any *.xxx
/tmp> ll *.xxx
-rw-rw-rw-+ 1 0 Mar 3 14:30 Anything.xxx
---
Works here on a local NTFS file system.
> (Failure in much the same way as mv would fail if the similar attempt was made.)
>
----
???
Like this?:
/tmp> touch anything.xxx
/tmp> mv anything.xxx Anything.xxx
/tmp> ll *.xxx
-rw-rw-rw-+ 1 0 Mar 3 14:30 Anything.xxx
/tmp> rename Any any *.xxx
> (Good old DOS command rename (or the abbreviation ren) used to achieve multiple-rename in an easy manner that just eludes bash.)
>
---
'rename' is not a bash builtin or feature, neither is 'mv' nor
my preference: 'mmv':
/tmp> ll *.xxx
-rw-rw-rw-+ 1 0 Mar 3 14:30 anything.xxx
/tmp> mmv 'a*.xxx' 'A#1.xxx' #(same as "mmv a\*.xxx A\#1.xxx' )
/tmp> ll *.xxx
-rw-rw-rw-+ 1 0 Mar 3 14:30 Anything.xxx
FWIW: w/mmv, meta chars like '*' in source and '#' in target need to be
quoted to protect from shell expansion.
> Anyway: has something altered (and quite recently, i think), or am I just mis-remembering the versatility of the command rename?
>
----
I think that the 'whatever' that has changed is likely a different
file system.
Besides the above tests/examples on Win7/NTFS, I got similar results
on a network share from a Linux-Samba server.
Oh -- one more potential gotcha:
the '*.xxx' pattern you are giving to rename is subject to shell
expansion (shell being bash in this case). If the *.xxx doesn't
match all your targets and bash doesn't have 'nocaseglob' set, you
can get:
/tmp> shopt -u nocaseglob nocasematch
/tmp> rename Anything anything *.xxx
rename: *.xxx: not accessible: No such file or directory
/tmp> shopt -s nocaseglob nocasematch
/tmp> rename Anything anything *.xxx
Why?: because my filename was 'Anything.Xxx' (Anything.XXX would do the
same).
Even though the file system ignores case, if bash is told
not to ignore case, the '*.xxx' won't match anything but all lower
case extensions.
It's a contrived case, but illustrates that the pattern at
the end isn't seen by 'rename' because it is 1st expanded by bash.
Hope this helps, and isn't overkill! ;-)
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2020-03-03 23:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 12:38 Fergus Daly
2020-02-28 18:09 ` Lee
2020-02-28 19:52 ` Brian Inglis
2020-02-29 8:27 ` Fergus Daly
2020-02-29 15:48 ` Brian Inglis
2020-03-04 3:52 ` L A Walsh [this message]
2020-03-04 5:09 ` Hans-Bernhard Bröker
2020-03-04 10:42 ` L A Walsh
2020-03-05 10:33 ` Hans-Bernhard Bröker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5E5EE76B.8000202@tlinx.org \
--to=cygwin@tlinx.org \
--cc=cygwin@cygwin.com \
--cc=fergusd84@outlook.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).