This apparently works. The trick was to use the $symlink_dir path as the
basepath (for the abs2rel function), and not $symlink. Kinda makes sense, really.
This commit is contained in:
@@ -5,7 +5,6 @@ use strict;
|
||||
|
||||
use File::Find::Wanted;
|
||||
use File::Basename;
|
||||
use Cwd qw/getcwd abs_path/;
|
||||
use File::Spec;
|
||||
use File::Spec::Functions;
|
||||
use Image::EXIF;
|
||||
@@ -39,7 +38,7 @@ if (! @list) {
|
||||
exit 0
|
||||
}
|
||||
|
||||
# get their information
|
||||
# extract the EXIF data from the files and build a hash from all that stuff
|
||||
my $count = 0; # how many files?
|
||||
my $errors = 0; # how many errors?
|
||||
my $ars = {}; # a hashref that holds all the encountered aspect rations and their number of occurence
|
||||
@@ -115,15 +114,19 @@ foreach my $f (keys %$files) {
|
||||
|
||||
# Construct the symlink path. TODO: use something smarter than just string
|
||||
# concatenation.
|
||||
my $ar = $files->{$f}->{ar};
|
||||
my $symlink_name = basename($f);
|
||||
my $symlink_dir = abs_path($conf->{dst_dir}) . "/" . $ar;
|
||||
my $symlink_path = File::Spec->abs2rel($symlink_dir . "/" . $symlink_name);
|
||||
|
||||
my $f_path = File::Spec->abs2rel(abs_path($f));
|
||||
print "\$f='$f' ";
|
||||
my $ar = $files->{$f}->{ar}; print "\$ar='$ar' ";
|
||||
my $symlink_dir = $conf->{dst_dir} . "/" . $ar; print "\$symlink_dir='$symlink_dir' ";
|
||||
my $symlink = $symlink_dir . "/" . basename($f); print "\$symlink='$symlink' ";
|
||||
my $symlink_dst = File::Spec->abs2rel(
|
||||
File::Spec->rel2abs($f),
|
||||
File::Spec->rel2abs($symlink_dir)
|
||||
); print "\$symlink_dst='$symlink_dst' ";
|
||||
print "\n";
|
||||
|
||||
# symlink
|
||||
print "symlink($f_path, $symlink_path);\n";
|
||||
print "symlink($symlink_dst, $symlink);\n";
|
||||
symlink($symlink_dst, $symlink);
|
||||
}
|
||||
|
||||
# vim: set ts=4 sw=4 et cc=80:
|
||||
|
||||
Reference in New Issue
Block a user