Author Topic: ignore symlinks does not work on windows  (Read 4831 times)

romain

  • Newbie
  • *
  • Posts: 9
ignore symlinks does not work on windows
« on: May 08, 2012, 06:04:04 AM »
Hello Phil !

I'm using Exiftool on *nix with pleasure for some time.

Since I'm testing it on windows, I experience a bug : symbolic links are followed when I set the -i SYMLINKS.

I'm using exiftool 8.89 on Windows 7 :

tree is :

c:\rootdir
  |- folder
  |  |- file1.txt
  |  |- symdir (link to folder2)
  |- folder2
     |- file2.txt

the command used is c:\exiftool\exiftool.exe -ext "*" -r -i SYMLINKS c:\rootdir\folder

expectd results : only file1.txt is found

Actual result : file1.txt and file2.txt are found.

Am I missing something ? Is it a bug ?

Romain
« Last Edit: May 08, 2012, 06:19:58 AM by romain »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16703
    • ExifTool Home Page
Re: ignore symlinks does not work on windows
« Reply #1 on: May 08, 2012, 07:27:50 AM »
I'll test this when I get access to a Windows machine.

I'm using the Perl -l operator to test for symlinks.  It appears that this may function differently (or not work at all) in Windows (not too surprising).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pb

  • Sr. Member
  • ****
  • Posts: 127
Re: ignore symlinks does not work on windows
« Reply #2 on: May 08, 2012, 03:24:27 PM »
This may be useless or trivial info, but at some point a couple of years ago I was looking to write some Perl code to deal with symlinks on windows, until I found someone who had done all the work already for me (in another language).  My vague recollection is that there is some package that will do the right thing for Windows.  I no longer recall what package, but I found it fairly rapidly with one or a few searches.  (This might be trivial if that package is just some Windows compatibility package;  sorry I don't recall more.)

--peter

EDIT:  I found some of my old code.  It says use Win32::Symlink;.  Unfortunately, I don't remember if I ever tested it.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16703
    • ExifTool Home Page
Re: ignore symlinks does not work on windows
« Reply #3 on: May 08, 2012, 07:58:13 PM »
Hi Peter,

Thanks, but I'm not sure if this helps.

Romain : I should ask though... how did you create the symlink?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16703
    • ExifTool Home Page
Re: ignore symlinks does not work on windows
« Reply #4 on: May 12, 2012, 05:53:08 AM »
I did some googling, but can't figure out how to create a symlink in Windows XP.

Vista apparently has a "mklink" command, but XP doesn't have this.  I read about a "linkd" command for XP, but my XP system doesn't have it.

From my reading it seems that symlinks aren't well supported in XP, so it doesn't surprise me if the Perl "-l" operator is broken on this platform.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pb

  • Sr. Member
  • ****
  • Posts: 127
Re: ignore symlinks does not work on windows
« Reply #5 on: May 12, 2012, 11:39:17 AM »
Windows has developed its own vocabulary for symlinks, including "junctions", "reparse points", and "symbolic links".

As I understand it, directory symlinks, known as "junctions" are available starting with the NTFS that is part of Windows 2000.  The most convenient tool I have found for creating and listing them is the "junction" utility from Sysinternals, which can be found here:  http://technet.microsoft.com/en-us/sysinternals/bb896768

File symlinks I believe are only supported starting with Vista.

There are various other tools around.  A particularly useful one I have found is this one:  http://schinagl.priv.at/nt/ln/ln.html

Since I installed the latter a long time ago, I forget whether it is needed for windows explorer to show the targets of symlinks, or whether explorer already does that natively.  (If you select the column "references", which will also show the hardlink count.)

Also, through win xp at least, only absolute symlinks exist, not relative.  I'm not sure about newer windows versions.

I believe the first tool for creating symlinks in windows was available in the win 2k resource kit;  I don't remember what it was called, maybe "ln".

--peter

pb

  • Sr. Member
  • ****
  • Posts: 127
Re: ignore symlinks does not work on windows
« Reply #6 on: May 12, 2012, 11:42:23 AM »
I should add that of course the various progs for creating symlinks rely on system calls that do so, which presumably Perl can also make.  However, it would have to be customized for windows rather than unix, since 'ln' either isn't available or doesn't have the desired effect.  The Perl package I referenced earlier is probably such a customization, and it most definitely does allow the creation and detection of symlinks in windows.

edit: of course Perl wouldn't have to go through 'ln', but presumably would call symlink() directly.  I don't know what the Windows system call would be for a junction.  Windows is supposed to be posix compatible, but it involves explicitly using some posix compatibility subsystem of windows, and at least in the past, compatibility was not complete.
« Last Edit: May 12, 2012, 12:08:12 PM by pb »

pb

  • Sr. Member
  • ****
  • Posts: 127
Re: ignore symlinks does not work on windows
« Reply #7 on: May 12, 2012, 04:36:12 PM »
This web page might also be of interest:  http://www.perlmonks.org/?node_id=958816

--peter

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16703
    • ExifTool Home Page
Re: ignore symlinks does not work on windows
« Reply #8 on: May 12, 2012, 07:27:20 PM »
Hi Peter,

Thanks for all of the information.  I'm away from a PC again right now, but you've given me some ideas.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pb

  • Sr. Member
  • ****
  • Posts: 127
Re: ignore symlinks does not work on windows
« Reply #9 on: May 12, 2012, 07:37:31 PM »
Glad to be of service.  Unfortunately, all of the possible solutions involve a lot more hacking than just saying "-l".

--peter