<?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: Script for file name change in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126026#M448709</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You could do this with 'sed'.  For example:&lt;BR /&gt;&lt;BR /&gt;# F=AQULEMPONesusyrloseK50SDS_AUSTRIAEnglish.key&lt;BR /&gt;&lt;BR /&gt;# echo ${F}|sed -e 's/_AUSTRIA/_AT/;s/English.key/E.key/'&lt;BR /&gt;AQULEMPONesusyrloseK50SDS_ATE.key&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
    <pubDate>Fri, 22 Aug 2008 16:47:36 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2008-08-22T16:47:36Z</dc:date>
    <item>
      <title>Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126024#M448707</link>
      <description>Hi All,&lt;BR /&gt;I am seeking a URGENT help for changing the filenames ( almost 45000+)&lt;BR /&gt;I need a script which will change ( basically reduce) the filenames. My filnaming convention basically like the following&lt;BR /&gt;&lt;PRODUCTNAME&gt;_&lt;COUNTRY&gt;.key&lt;BR /&gt;example of the filenames are following..&lt;BR /&gt;&lt;BR /&gt;AQULEMPONesusyrloseK50SDS_AUSTRIAEnglish.key&lt;BR /&gt;AQUARECOnfjesseK50SDS_FINLANDFinnish.key&lt;BR /&gt;AMBELOndijsjd_THE_NETHERLANDSCzech.key&lt;BR /&gt;BLANOSERefinedCMC7H4XSDS_BULGARIAItalian.key&lt;BR /&gt;&lt;BR /&gt;if you notice the second part of the file name have countryname and language name together. This is the area where we are trying to reduce the characters. Each country and name has to be shorten as per the given standard. some example given below.&lt;BR /&gt;&lt;BR /&gt;Country substitutes:&lt;BR /&gt;AUSTRIA AT &lt;BR /&gt;BELGIUM BE  &lt;BR /&gt;BULGARIA BG &lt;BR /&gt;CZECH CZ &lt;BR /&gt;DENMARK DK &lt;BR /&gt;&lt;BR /&gt;Languages substitutes:&lt;BR /&gt;English  E&lt;BR /&gt;German  D&lt;BR /&gt;Italian  I&lt;BR /&gt;Spanish  S&lt;BR /&gt;Finnish  U&lt;BR /&gt;so what I am expecting is the replace ment like in the bewlow example&lt;BR /&gt;&lt;BR /&gt;Original file:&lt;BR /&gt;AMBERGUMTEMPROES_THE_NETHERLANDSEnglish.key&lt;BR /&gt;New file name:&lt;BR /&gt;AMBERGUMTEMPROES_THE_NLE.key&lt;BR /&gt;&lt;BR /&gt;Can anyone please help me on this?&lt;BR /&gt;&lt;BR /&gt;SKR&lt;/COUNTRY&gt;&lt;/PRODUCTNAME&gt;</description>
      <pubDate>Fri, 22 Aug 2008 16:33:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126024#M448707</guid>
      <dc:creator>SKR_1</dc:creator>
      <dc:date>2008-08-22T16:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126025#M448708</link>
      <description>Why opening another one ??? &lt;BR /&gt;&lt;BR /&gt;Patience young grasshopper..&lt;BR /&gt;&lt;BR /&gt;Here is one example of a way. Use a case statement for each lang, then instead of echoing use the mv command to rename.&lt;BR /&gt;&lt;BR /&gt;ls /tmp/file*|while read file&lt;BR /&gt;do&lt;BR /&gt;        case $file in&lt;BR /&gt;                *nether*)       NEW=`echo $file|sed -e s/nether_eng/NED_ENG/g'&lt;BR /&gt;                         echo $NEW;;&lt;BR /&gt;                        *)      echo "no match"&lt;BR /&gt;        esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2008 16:39:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126025#M448708</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-08-22T16:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126026#M448709</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You could do this with 'sed'.  For example:&lt;BR /&gt;&lt;BR /&gt;# F=AQULEMPONesusyrloseK50SDS_AUSTRIAEnglish.key&lt;BR /&gt;&lt;BR /&gt;# echo ${F}|sed -e 's/_AUSTRIA/_AT/;s/English.key/E.key/'&lt;BR /&gt;AQULEMPONesusyrloseK50SDS_ATE.key&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2008 16:47:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126026#M448709</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-22T16:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126027#M448710</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Of course, you don't say whether or not these filenames (all 45,000) are actually *files* you want to rename or are *filenames* in some file.  Knowing that distinction would make the solution suggested easier.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 22 Aug 2008 16:50:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126027#M448710</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-22T16:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126028#M448711</link>
      <description>Hi.. Thanks to all for the quick response.&lt;BR /&gt;They all are individual files stored under one directory. I want to rename these file names</description>
      <pubDate>Fri, 22 Aug 2008 16:54:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126028#M448711</guid>
      <dc:creator>SKR_1</dc:creator>
      <dc:date>2008-08-22T16:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126029#M448712</link>
      <description>Hi &lt;BR /&gt;One more update&lt;BR /&gt;When we replace the country, sometime language will also get change.&lt;BR /&gt;for ex: if I want to change CZECHCzech.key, both will get replaced. What I need is CZECH( country name) should be replaced with CZ and Czech ( Language) with C&lt;BR /&gt;Note: All country names are in uppercase. while langaguages first character is uppercase and remining will be lower case. &lt;BR /&gt;ex.&lt;BR /&gt;CZECH - country name&lt;BR /&gt;Czech - language</description>
      <pubDate>Fri, 22 Aug 2008 16:59:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126029#M448712</guid>
      <dc:creator>SKR_1</dc:creator>
      <dc:date>2008-08-22T16:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126030#M448713</link>
      <description>How bout run it the first time to fix CZECH and then another time with mods to fix Czech ? ( too much brain power for a Friday to fix all options in one sweep)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2008 17:12:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126030#M448713</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-08-22T17:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126031#M448714</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; When we replace the country, sometime language will also get change.&lt;BR /&gt;for ex: if I want to change CZECHCzech.key, both will get replaced. What I need is CZECH( country name) should be replaced with CZ and Czech ( Language) with C&lt;BR /&gt;&lt;BR /&gt;Consider:&lt;BR /&gt;&lt;BR /&gt;# F=AQULEMPONesusyrloseK50SDS_CZECHCzech.key&lt;BR /&gt;# echo $F|sed -e 's/_CZECH/_CZ/;s/Czech.key/C.key/'&lt;BR /&gt;AQULEMPONesusyrloseK50SDS_CZC.key&lt;BR /&gt;&lt;BR /&gt;Now, since you are acutally renaming files, Tim's initial approach is fine insofar as the driving code.  Simply add a 'mv' of the original filename to the new filename.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2008 17:45:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126031#M448714</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-22T17:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126032#M448715</link>
      <description>Basically as Tim and JRF have said, you can use sed(1) to change the names.  (You may want to put some separator between the country and language so you could change them back.)&lt;BR /&gt;&lt;BR /&gt;If you only have less than 100 changes, you can just use one long sed command or script file.&lt;BR /&gt;NEW=$(echo ${F} | sed -e 's/AUSTRIA/AT/' \&lt;BR /&gt;-e 's/BELGIUM/BE/' \&lt;BR /&gt;...&lt;BR /&gt;-e 's/English/_E/' \&lt;BR /&gt;...&lt;BR /&gt;)&lt;BR /&gt;(I inserted a "_" before the language.)&lt;BR /&gt;&lt;BR /&gt;Then just:&lt;BR /&gt;mv $(F) $(NEW)&lt;BR /&gt;&lt;BR /&gt;You may want to echo the above mv so you can check whether your script is correct.&lt;BR /&gt;&lt;BR /&gt;Also, a meta question is: How do I write a script to write that sed script?&lt;BR /&gt;Give your above input in a file "map", you would write an awk script to turn it into the sed script file:&lt;BR /&gt;Country substitutes:&lt;BR /&gt;AUSTRIA AT&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Languages substitutes:&lt;BR /&gt;English E&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;NF == 2 &amp;amp;&amp;amp; $2 != "substitutes" {&lt;BR /&gt;print "s/" $1 "/" $2 "/"&lt;BR /&gt;}' map &amp;gt; sed_script_file&lt;BR /&gt;&lt;BR /&gt;Then use "sed -f sed_script_file".</description>
      <pubDate>Sat, 23 Aug 2008 01:58:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126032#M448715</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-23T01:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126033#M448716</link>
      <description>&lt;!--!*#--&gt;I would do this with a perl script (some reader will not be surprised :-)...&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;---------- translate.pl ---------&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my %countries = qw(&lt;BR /&gt;AUSTRIA AT&lt;BR /&gt;BELGIUM BE&lt;BR /&gt;BULGARIA BG&lt;BR /&gt;CZECH CZ&lt;BR /&gt;DENMARK DK&lt;BR /&gt;NETHERLANDS NL&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;my %languages = qw(&lt;BR /&gt;English E&lt;BR /&gt;German D&lt;BR /&gt;Italian I&lt;BR /&gt;Spanish S&lt;BR /&gt;Finnish U&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  chomp;&lt;BR /&gt;  my $old = $_;&lt;BR /&gt;  if (/_([A-Z]+)([A-Z][a-z]+)\./) {&lt;BR /&gt;    my $country = $countries{$1};&lt;BR /&gt;    my $language = $languages{$2};&lt;BR /&gt;    if (!defined($country)) { &lt;BR /&gt;        print STDERR "Unknown Country $1 from $old \n";&lt;BR /&gt;        next&lt;BR /&gt;    }&lt;BR /&gt;    if (!defined($language)) {&lt;BR /&gt;        print STDERR "Unknown Language $2 from $old \n"; &lt;BR /&gt;        next&lt;BR /&gt;    }&lt;BR /&gt;    my $new = $` . '_' . $country . $language . '.' . $';&lt;BR /&gt;    print "rename $old, $new;\n";&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;----------------------&lt;BR /&gt;&lt;BR /&gt;Using the files you list runs as:&lt;BR /&gt;&lt;BR /&gt;$ ls tmp/*.key | perl translate.pl | more&lt;BR /&gt;Unknown Language Czech from tmp/AMBELOndijsjd_THE_NETHERLANDSCzech.key&lt;BR /&gt;Unknown Country FINLAND from tmp/AQUARECOnfjesseK50SDS_FINLANDFinnish.key&lt;BR /&gt;rename tmp/AQULEMPONesusyrloseK50SDS_AUSTRIAEnglish.key, tmp/AQULEMPONesusyrloseK50SDS_ATE.key;&lt;BR /&gt;rename tmp/BLANOSERefinedCMC7H4XSDS_BULGARIAItalian.key, tmp/BLANOSERefinedCMC7H4XSDS_BGI.key;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When you like what you see, change that last print statement into the real rename:&lt;BR /&gt;    rename $old, $new;&lt;BR /&gt;&lt;BR /&gt;Enjoy!&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Aug 2008 02:40:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126033#M448716</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-08-23T02:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126034#M448717</link>
      <description>&lt;!--!*#--&gt;I meant to add a generic unrecognide file warning.&lt;BR /&gt;&lt;BR /&gt;Change &lt;BR /&gt;    rename $old, $new;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;To &lt;BR /&gt;    rename $old, $new;&lt;BR /&gt;  } else {&lt;BR /&gt;    print STDERR "Unrecognized file: $old\n"&lt;BR /&gt;  }&lt;BR /&gt;    &lt;BR /&gt;fwiw... I thought it was a nice twist to be able to retain the suggested tables verbatim for inclusing in loading the translation array.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Aug 2008 03:53:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126034#M448717</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-08-23T03:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126035#M448718</link>
      <description>Thanks to all of you for helping me.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;SKR</description>
      <pubDate>Mon, 25 Aug 2008 08:13:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126035#M448718</guid>
      <dc:creator>SKR_1</dc:creator>
      <dc:date>2008-08-25T08:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script for file name change</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126036#M448719</link>
      <description>&amp;gt;Thanks to all of you for helping me.&lt;BR /&gt;&lt;BR /&gt;If you have gotten the answers you wanted, please read the following about assigning points and reopening threads:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/helptips.do?#41" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/helptips.do?#41&lt;/A&gt;</description>
      <pubDate>Mon, 25 Aug 2008 21:16:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-file-name-change/m-p/5126036#M448719</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-25T21:16:09Z</dc:date>
    </item>
  </channel>
</rss>

