holzschu / holzschu/a-shell

convmv error

Open
#871 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Perl
Stars
3.9k
Forks
213
Avg merge
1m
Merged PRs (30d)
1

Description

convmv error

Hi. convmv is a perl script which can be found at:

https://github.com/skangas/home-bin/blob/master/convmv

This is a file renaming tool and at first it seemed to work fine in a-Shell, but I noticed that --replace option does not actually work.

The best solution for now that I found is to use --exec "pbcopy mv #1 #2.new" option instead of using --replace and manually run the command which is copied to the clipboard. FYI, --exec "pbcopy mv #1 #2" did not work because mv command did not recognize the difference of the two file names.

Now I'm wondering if you can look into the perl code and identify what causes the problem in a-Shell.

For your convenience, please find below a part of the entire code:

```perl
sub renameit() {
my $oldfile=shift;
my $newname=shift;
my $cmd;
$newname=encode_utf8($newname) if ($to_is_utf8);
if ($opt_exec) {
$cmd = $opt_exec;
$cmd =~ s/\#2/\000f8d9hqoäd\#2/g; # make the #2 unique so that file names may contain "#2"
$cmd =~ s/\#1/\Q$oldfile\E/g;
$cmd =~ s/\000f8d9hqoäd\#2/\Q$newname\E/g;
print "$cmd\n";
} else {
#print is_utf8($oldfile) ? 1 : 0;
#print is_utf8($newname) ? 1 : 0;
&print_ask ("mv \"". &$from_print($dir.$oldfile)."\"\t\"".&$from_print($dir).&$to_print($newname)."\"",$opt_i) or return;
}
if (-e $newname and !$opt_exec) {
if ($opt_replace and !&compare($oldfile,$newname)) {
if ($opt_notest) {
unlink $newname or print STDERR "Error: $!\n";
rename ($oldfile, $newname) or print STDERR "Error: $!\n";
}
} else {
print STDERR &$to_print($newname)," exists and differs or --replace option missing - skipped\n";
}
} else {
if ($opt_notest) {
if ($opt_exec) {
system($cmd);
} else {
rename ($oldfile, $newname) or print STDERR "Error: $!\n";
}
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.