servicewidget/themes/install-themes/rename_localized_xuikon_odts.pl
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:33:36 +0100
branchRCL_3
changeset 29 9a48e301e94b
parent 0 5e5d6b214f4f
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

#
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Nokia Corporation - initial contribution.
#
# Contributors:
#
# Description: 
#
#!/usr/bin/perl
use File::Copy;
use File::Find;

print("Start to move localized xuikon odts to folders named by language number\n");

# go through all directories and subdirectories
find(\&MoveLocalized, '.');

sub MoveLocalized
{
  # if we are in hsps folder move localized xuikon odts
  if ($File::Find::name =~ /\/hsps\//g)
  {
    #print("Processing folder $File::Find::dir\n");
    $File::Find::prune = 1;
    # move localized xuikon odts to folders named by language index
    while(<*.o*>)
    {
      # Find position of suffix (search for ".o")
      $suffix = $_;
      $suffix =~ /\.o/g;
    
      # name of localized dir is last four characters of file
      $dirname = substr($_, pos($suffix), 4);
      # don't move engineering english version
      if ($dirname != "0000")
      {
        print("\nold file = $File::Find::dir/$_\n");
        # remove zeros from beginning
        $dirname += 0;
        # create folder
        mkdir($dirname);
        # move file to folder and rename it
        $newlocation = $dirname ."/" .$_;
        move($_, $newlocation);
        $oldname = $newlocation;
        $newlocation =~ s/\.o(.*)$/\.o0000/;
        print("new file = $File::Find::dir/$newlocation\n");
        rename $oldname, $newlocation;
      }
    }
  }
}


exit;