Re: project clone
Re: project clone
- Subject: Re: project clone
- From: Dmitry Markman <email@hidden>
- Date: Thu, 06 Oct 2011 23:01:46 -0400
I'm not a good perl programmer, but here is a script that rename progect with old_name to new_name
it actually rename any file/dir that contain old_name to new_name
after that it check all files inside of the project hierarchie and substitute content of the files that contains old_name to new_name\
it looks like it works
#!/usr/bin/perl
use File::Find;
my %files_to_rename;
my $name_to_find = "old_name";
my $name_to_replace = "new_name";
my $sandbox=<path_to_folder_with_project>;
chdir $sandbox or die "cannot chdir to $sandbox: $!";
find(\&handle_project_files, $sandbox);
while ( ($key, $value) = each %files_to_rename ) {
rename $key,$value or die "cannot rename to $key to $value: $!";
}
sub handle_project_files
{
my $old_name = $_;
my $new_name = $old_name;
if( -f $File::Find::dir."/".$old_name) {
my $file_path = $File::Find::dir."/".$old_name;
my $file_content = `cat $file_path`;
my $file_need_to_change = ($file_content =~ s/\b$name_to_find\b/$name_to_replace/g);
if($file_need_to_change) {
print "$file_path\n";
open FILE, ">$file_path" or die "wasn't able to open $file_path for write. ($!)";
print FILE $file_content;
close FILE;
}
}
my $was_changed = ($new_name =~ s/\b$name_to_find\b/$name_to_replace/);
if($was_changed) {
$old_name = $File::Find::dir."/".$old_name;
$new_name = $File::Find::dir."/".$new_name;
$files_to_rename{$old_name} .= $new_name; # creates the element if needed
# print "$_\n";
}
}
On Oct 5, 2011, at 12:57 PM, Koen van der Drift wrote:
> Hi,
>
> Is there a way to clone a project and save it under a different name,
> without needing to go all over Xcode to make sure I didn't miss any
> setting that needs to be changed?
>
> - Koen.
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
Dmitry Markman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >project clone (From: Koen van der Drift <email@hidden>) |