<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic renaming multiple files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/renaming-multiple-files/m-p/4477533#M362134</link>
    <description>Hi there --&lt;BR /&gt;&lt;BR /&gt;I want to rename multiple files in a directory using the rename command. For example, a typical file looks like the following:&lt;BR /&gt;&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1 (1).ALAN&lt;BR /&gt;&lt;BR /&gt;I would like to renaming all such files to read as follows:&lt;BR /&gt;&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1.1.ALAN&lt;BR /&gt;&lt;BR /&gt;What command syntax can I use to facilitate renaming all the files in question? Thanks. &lt;BR /&gt;</description>
    <pubDate>Tue, 11 Aug 2009 21:04:54 GMT</pubDate>
    <dc:creator>Andrew Kaplan</dc:creator>
    <dc:date>2009-08-11T21:04:54Z</dc:date>
    <item>
      <title>renaming multiple files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/renaming-multiple-files/m-p/4477533#M362134</link>
      <description>Hi there --&lt;BR /&gt;&lt;BR /&gt;I want to rename multiple files in a directory using the rename command. For example, a typical file looks like the following:&lt;BR /&gt;&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1 (1).ALAN&lt;BR /&gt;&lt;BR /&gt;I would like to renaming all such files to read as follows:&lt;BR /&gt;&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1.1.ALAN&lt;BR /&gt;&lt;BR /&gt;What command syntax can I use to facilitate renaming all the files in question? Thanks. &lt;BR /&gt;</description>
      <pubDate>Tue, 11 Aug 2009 21:04:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/renaming-multiple-files/m-p/4477533#M362134</guid>
      <dc:creator>Andrew Kaplan</dc:creator>
      <dc:date>2009-08-11T21:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: renaming multiple files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/renaming-multiple-files/m-p/4477534#M362135</link>
      <description>I like to use perl for these tasks to have the full power of regular expression for the job.&lt;BR /&gt;&lt;BR /&gt;You for not indicate the exact replace pattern, but I suspect you want to replace a s "space plus number in parens" by a "period plus that number". Correct?&lt;BR /&gt;&lt;BR /&gt;Here is a working example:&lt;BR /&gt;&lt;BR /&gt;$ cat &amp;gt; "CTI.123456789.987654321-1601-XY.48.1 (1).ALAN"&lt;BR /&gt;test&lt;BR /&gt;$ dir *.ALAN&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1\ (1).ALAN&lt;BR /&gt;&lt;BR /&gt;# first try with a PRINT instead of rename.&lt;BR /&gt;&lt;BR /&gt;$ perl -e 'for (&amp;lt;*ALAN&amp;gt;){ $o=$_; s/\s+\((\d+)\)/.$1/; print qq($o, $_\n)}'&lt;BR /&gt;&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1 (1).ALAN, CTI.123456789.987654321-1601-XY.48.1.1.ALAN&lt;BR /&gt;&lt;BR /&gt;# Looks ok? Go!&lt;BR /&gt;&lt;BR /&gt;$ perl -e 'for (&amp;lt;*ALAN&amp;gt;){ $o=$_; s/\s+\((\d+)\)/.$1/; rename $o, $_}'&lt;BR /&gt;&lt;BR /&gt;$ dir *.ALAN&lt;BR /&gt;CTI.123456789.987654321-1601-XY.48.1.1.ALAN&lt;BR /&gt;&lt;BR /&gt;explanation:&lt;BR /&gt;&lt;BR /&gt;perl -e '...'  # immediate perl program&lt;BR /&gt;&lt;BR /&gt;for (&amp;lt;*ALAN&amp;gt;){ ... } # 'glob' through all files ending in ALAN getting the names in variable $_, executing { ...} for each.&lt;BR /&gt;&lt;BR /&gt;$o = $_  # Stash away the original name.&lt;BR /&gt;&lt;BR /&gt;s/\s+\((\d+)\)/.$1/;  # The replace needed.&lt;BR /&gt;&lt;BR /&gt;rename $o, $_   # do the deed.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Aug 2009 21:25:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/renaming-multiple-files/m-p/4477534#M362135</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-08-11T21:25:03Z</dc:date>
    </item>
  </channel>
</rss>

