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:
Uroš Golja
2016-11-12 12:25:41 +01:00
parent d85735ef46
commit 1a7507c6bc

View File

@@ -5,7 +5,6 @@ use strict;
use File::Find::Wanted; use File::Find::Wanted;
use File::Basename; use File::Basename;
use Cwd qw/getcwd abs_path/;
use File::Spec; use File::Spec;
use File::Spec::Functions; use File::Spec::Functions;
use Image::EXIF; use Image::EXIF;
@@ -39,7 +38,7 @@ if (! @list) {
exit 0 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 $count = 0; # how many files?
my $errors = 0; # how many errors? my $errors = 0; # how many errors?
my $ars = {}; # a hashref that holds all the encountered aspect rations and their number of occurence 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 # Construct the symlink path. TODO: use something smarter than just string
# concatenation. # concatenation.
my $ar = $files->{$f}->{ar}; print "\$f='$f' ";
my $symlink_name = basename($f); my $ar = $files->{$f}->{ar}; print "\$ar='$ar' ";
my $symlink_dir = abs_path($conf->{dst_dir}) . "/" . $ar; my $symlink_dir = $conf->{dst_dir} . "/" . $ar; print "\$symlink_dir='$symlink_dir' ";
my $symlink_path = File::Spec->abs2rel($symlink_dir . "/" . $symlink_name); my $symlink = $symlink_dir . "/" . basename($f); print "\$symlink='$symlink' ";
my $symlink_dst = File::Spec->abs2rel(
my $f_path = File::Spec->abs2rel(abs_path($f)); File::Spec->rel2abs($f),
File::Spec->rel2abs($symlink_dir)
); print "\$symlink_dst='$symlink_dst' ";
print "\n";
# symlink # 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: # vim: set ts=4 sw=4 et cc=80: