<?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 Re: [Q] How can I rename all files with partially repeated filename ?? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957377#M415002</link>
    <description>Sorry about that. I just copied your filename. Remove the ./ from the for statement as in:&lt;BR /&gt; &lt;BR /&gt; for MYFILE in ????_??05&lt;BR /&gt; &lt;BR /&gt;./ is normally used for executables in the current directory. The complete script should look like this:&lt;BR /&gt; &lt;BR /&gt;cd /your_directory&lt;BR /&gt;for MYFILE in ????_??05&lt;BR /&gt;do&lt;BR /&gt;CHR7=$(echo $MYFILE | cut -c 1-7)&lt;BR /&gt;echo mv $MYFILE "${CHR7}00"&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;As mentioned, you can also use the full pathname (such as /var/opt/my_program/????_??05) but you would then change the cut command to specify all but the last 2 characters. A production script would accept the directory on the command line, validate that the directory exists, then validate that there is at least one file that matches the 9-character mask for the filename, and so on...</description>
    <pubDate>Sun, 05 Feb 2006 12:56:41 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2006-02-05T12:56:41Z</dc:date>
    <item>
      <title>[Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957370#M414995</link>
      <description>I am usually gathering license usage log file using cronjob.&lt;BR /&gt;So those files have partially repeated file name like this..&lt;BR /&gt;&lt;BR /&gt;./0126_1105&lt;BR /&gt;./0126_1405&lt;BR /&gt;./0126_1605&lt;BR /&gt;./0127_0905&lt;BR /&gt;./0127_1005&lt;BR /&gt;./0127_1105&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;this file is text format without any extension.&lt;BR /&gt;&lt;BR /&gt;As you can see, the end of file is xxxx-xxx05. And now I should replace that name 05 to 00.&lt;BR /&gt;&lt;BR /&gt;How can I rename all files in same directory without manually renaming one by one to use "mv" command.&lt;BR /&gt;&lt;BR /&gt;It is alright using awk, sed or whatever.&lt;BR /&gt;&lt;BR /&gt;Maybe using shell is better. I guess it is more comvenient. but I'm not good at shell programming.&lt;BR /&gt;&lt;BR /&gt;Any method is OK. And I will try to solve this rename issue.&lt;BR /&gt;&lt;BR /&gt;please let me know how can I successfully rename all files.&lt;BR /&gt;&lt;BR /&gt;thanks in advance</description>
      <pubDate>Sat, 04 Feb 2006 10:11:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957370#M414995</guid>
      <dc:creator>Tony, Lim</dc:creator>
      <dc:date>2006-02-04T10:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957371#M414996</link>
      <description>If and only if all the files are 9 characters and always have the underscore _ at character position 5, you can do it quite easily with a shell script. First, verify that this command exactly matches all the needed filenames:&lt;BR /&gt; &lt;BR /&gt;cd /whatever_directory&lt;BR /&gt;echo ./????_??05&lt;BR /&gt; &lt;BR /&gt;What this does is to match all 9 character filenames with _ in the middle and 05 on the end. If correct, make a backup of all the files in the directory, then use this script:&lt;BR /&gt; &lt;BR /&gt;for MYFILE in ./????_??05&lt;BR /&gt;do&lt;BR /&gt;CHR7=$(echo $MYFILE | cut -c 1-7)&lt;BR /&gt;echo mv $MYFILE "${CHR7}05"&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Now the above script has echo in front of the mv for testing. Run the script and check the output. It should produce a list of all the changes. If OK, remove the echo and let it run. NOTE: this works on a reasonable number of  files (several dozen). If there are thousands of files, the technique will need modification to handle extremely long lists.</description>
      <pubDate>Sat, 04 Feb 2006 10:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957371#M414996</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-02-04T10:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957372#M414997</link>
      <description>Hi Tony:&lt;BR /&gt;&lt;BR /&gt;If you file of filenames consists of one filename per line, then this will change the name of any file ending with "05" to one with the "05" changed to "00".&lt;BR /&gt;&lt;BR /&gt;The change is only made at the end of the filename.&lt;BR /&gt;&lt;BR /&gt;# cd your_directory&lt;BR /&gt;# perl -ne 'chomp;next unless m%05$%;$old=$_;s%05$%00%;system("mv $old $_")' files_to_rename&lt;BR /&gt;&lt;BR /&gt;If your 'files_to_rename' list of names specifies absolute path names, then there is no need to do the 'cd your_directory'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 04 Feb 2006 10:53:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957372#M414997</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-04T10:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957373#M414998</link>
      <description>Whoops, one typo. The mv line should end with 00 and not 05. This is the reason to run a test before the actual change. It should read:&lt;BR /&gt; &lt;BR /&gt;echo mv $MYFILE "${CHR7}00"</description>
      <pubDate>Sat, 04 Feb 2006 10:54:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957373#M414998</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-02-04T10:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957374#M414999</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Variation on the perl solution using an 'implied' GLOB function:&lt;BR /&gt;&lt;BR /&gt;perl -e "while (&amp;lt;*-*05&amp;gt;) {$old=$_; s/05$/00/; rename $old, $_}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Feb 2006 11:17:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957374#M414999</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-04T11:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957375#M415000</link>
      <description>Hi Tony,&lt;BR /&gt;&lt;BR /&gt;Try the awk construct below:&lt;BR /&gt;&lt;BR /&gt;# ls -1 &lt;FILES dir=""&gt; | awk '{l=length()-2;x=substr($0,1,l);system("mv "$0" "x"00")}'&lt;BR /&gt;&lt;BR /&gt;hope it helps!&lt;/FILES&gt;</description>
      <pubDate>Sun, 05 Feb 2006 04:34:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957375#M415000</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-02-05T04:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957376#M415001</link>
      <description>As Bill hassell mentioned before, belows are helpful to me.&lt;BR /&gt;&lt;BR /&gt;# for MYFILE in ./????_??05&lt;BR /&gt;&amp;gt;do&lt;BR /&gt;&amp;gt;CHR7=$(echo $MYFILE | cut -c 1-7)&lt;BR /&gt;&amp;gt;mv $MYFILE "${CHR7}00"&lt;BR /&gt;&amp;gt;done&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;But, ./????_??05 and cut -c 1-7 have some troubles.&lt;BR /&gt;&lt;BR /&gt;character 1-7 included "./" so it resulted like this.&lt;BR /&gt;&lt;BR /&gt;./????_00 not ./????_??00&lt;BR /&gt;&lt;BR /&gt;What command is being needed to change without previous troubles ??</description>
      <pubDate>Sun, 05 Feb 2006 08:31:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957376#M415001</guid>
      <dc:creator>Tony, Lim</dc:creator>
      <dc:date>2006-02-05T08:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: [Q] How can I rename all files with partially repeated filename ??</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957377#M415002</link>
      <description>Sorry about that. I just copied your filename. Remove the ./ from the for statement as in:&lt;BR /&gt; &lt;BR /&gt; for MYFILE in ????_??05&lt;BR /&gt; &lt;BR /&gt;./ is normally used for executables in the current directory. The complete script should look like this:&lt;BR /&gt; &lt;BR /&gt;cd /your_directory&lt;BR /&gt;for MYFILE in ????_??05&lt;BR /&gt;do&lt;BR /&gt;CHR7=$(echo $MYFILE | cut -c 1-7)&lt;BR /&gt;echo mv $MYFILE "${CHR7}00"&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;As mentioned, you can also use the full pathname (such as /var/opt/my_program/????_??05) but you would then change the cut command to specify all but the last 2 characters. A production script would accept the directory on the command line, validate that the directory exists, then validate that there is at least one file that matches the 9-character mask for the filename, and so on...</description>
      <pubDate>Sun, 05 Feb 2006 12:56:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/q-how-can-i-rename-all-files-with-partially-repeated-filename/m-p/4957377#M415002</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-02-05T12:56:41Z</dc:date>
    </item>
  </channel>
</rss>

