X-Recipient: archive-cygwin@delorie.com
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 093973858D3C
Authentication-Results: sourceware.org;
 dmarc=none (p=none dis=none) header.from=cs.umass.edu
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.umass.edu
Subject: Re: rename using regexpr - is it possible?
To: Fergus Daly <fergusd84@outlook.com>,
        "'cygwin@cygwin.com'" <cygwin@cygwin.com>
References: <DB6PR03MB3013B1F610224113A9D3E761A4829@DB6PR03MB3013.eurprd03.prod.outlook.com>
 <1edc0f18-60e9-8769-e931-2875e910cb9e@cs.umass.edu>
 <DB6PR03MB3013A14DF42627BBBDC0C44AA4829@DB6PR03MB3013.eurprd03.prod.outlook.com>
From: Eliot Moss <moss@cs.umass.edu>
Message-ID: <9b435ec1-7920-4ae4-8867-38913e4bebac@cs.umass.edu>
Date: Sun, 24 Oct 2021 17:11:01 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <DB6PR03MB3013A14DF42627BBBDC0C44AA4829@DB6PR03MB3013.eurprd03.prod.outlook.com>
Content-Language: en-US
X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL,
 KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS,
 TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
Reply-To: moss@cs.umass.edu
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On 10/24/2021 4:55 PM, Fergus Daly wrote:
>>> I might be wrong but:
>>> The Cygwin implementation of rename seems completely different from "the" (my) Linux version.
>>> (Almost unique? Otherwise the matching in Cygwin of all syntax -
>>> vocab, switches, outcomes - to Linux, seems almost perfect.)
>>> Can I rename a set of files *.d (say) as filename.d -> XXfilename.d?
>>> In Linux this would be achieved by
>>> $ rename 's/^/XX/g' ./*.d
>>> whereas in Cygwin
>>> $ rename ^ XX *.d
>>> (and all similar attempts) fails.
>>> Thank you.
> 
>> You're confusing perl-rename with util-linu rename.
>> The former, which seems to be what you want, can be installed using cpan (install File::Rename),
>> assuming you have perl installed.
>> It will put its rename command in /usr/local/bin, presumably taking precedence over the util-linux one in /usr/bin.
>> It further seems that "normally" these two have different names, like rename.ul and prename,
>> and /etc/alternatives is used to set up the rename command.
>> This required some web searching to determine ...
>> Cheers - Eliot
> 
> Perfect. Worked like a dream.
> All in place, and naming managed.
> Thanks so much.

No problem - learned something myself!  EM

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
