From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56014 invoked by alias); 3 Mar 2020 23:25:38 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 56006 invoked by uid 89); 3 Mar 2020 23:25:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,SPF_PASS autolearn=ham version=3.3.1 spammy=meta X-HELO: Ishtar.sc.tlinx.org Received: from ishtar.tlinx.org (HELO Ishtar.sc.tlinx.org) (173.164.175.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Mar 2020 23:25:37 +0000 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id 023NPVT3053260; Tue, 3 Mar 2020 15:25:34 -0800 Message-ID: <5E5EE76B.8000202@tlinx.org> Date: Wed, 04 Mar 2020 03:52:00 -0000 From: L A Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: Fergus Daly , "cygwin@cygwin.com" Subject: Re: Has rename syntax changed? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-03/txt/msg00062.txt 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