win32file.CreateHardLink

CreateHardLink(FileName, ExistingFileName, SecurityAttributes, Transaction)

Establishes an NTFS hard link between an existing file and a new file.

Parameters

FileName : PyUnicode

The name of the new directory entry to be created.

ExistingFileName : PyUnicode

The name of the existing file to which the new link will point.

SecurityAttributes=None : PySECURITY_ATTRIBUTES

Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None

Transaction=None : PyHANDLE

Handle to a transaction, as returned by win32transaction::CreateTransaction

Comments

An NTFS hard link is similar to a POSIX hard link.
This function creates a second directory entry for an existing file, can be different name in same directory or any name in a different directory. Both file paths must be on the same NTFS volume.
To remove the link, simply delete it and the original file will still remain.

This method exists on Windows 2000 and later. Otherwise NotImplementedError will be raised.

Accepts keyword args.

If the Transaction parameter is specified, CreateHardLinkTransacted will be called (requires Vista or later)

Example

Usage

CreateHardLink('h:\\dir\\newfilename.txt','h:\\otherdir\\existingfile.txt')