4
« on: December 26, 2015, 23:35:11 »
Hello,
I try to create a hard link to a file using script, but it doesn't do anythink. Can someone look at where I am wrong, please?
Thank you
Lukas
@var $selectedPaths = GetSourceSelectedPaths();
@var $targetPath = GetTargetPath();
//LogDumpArray($selectedPaths);
//LogDump($targetPath);
@var $sourcePathParts = StrSplit(PathGetPathPart($selectedPaths[0]), "\\");
@var $targetPathParts = StrSplit($targetPath, "\\");
//LogDumpArray( $sourcePathParts );
//LogDumpArray( $targetPathParts );
@var $counts = arrayCount($sourcePathParts);
@var $countt = arrayCount($targetPathParts);
@var $count = $countt;
if ($counts < $countt)
{
$count = $counts;
}
@var $i;
for( $i = 0; $i < $count; $i++ )
{
@var $cmp = StrIsEqualNoCase($sourcePathParts[$i], $targetPathParts[$i]);
if ($cmp == 0)
{
break;
}
}
@var $diffInx = $i;
@var $sourcePathRel = ".";
if ($i == 0)
{
$sourcePathRel = $sourcePath;
}
else
{
for( $i = $diffInx; $i < $counts; $i++ )
{
$sourcePathRel += "\\" + $sourcePathParts[$i];
}
$sourcePathRel = StrTrimLeft($sourcePathRel, ".\\");
}
@var $targetPathRel = ".";
if ($i == 0)
{
$targetPathRel = $targePath;
}
else
{
for( $i = $diffInx; $i < $countt; $i++ )
{
$targetPathRel += "\\" + $targetPathParts[$i];
}
$targetPathRel = StrTrimLeft($targetPathRel, ".\\");
}
//LogDump($sourcePathRel);
//LogDump($targetPathRel);
$count = arrayCount($selectedPaths);
for( $i = 0; $i < $count; $i++ )
{
@var $file = PathGetNamePart($selectedPaths[$i]);
@var $sourceFile = $sourcePathRel ^ $file;
@var $targetFile = $targetPathRel ^ $file;
//LogDump($sourceFile);
//LogDump($targetFile);
MC.Utils.CreateLink ASADMIN LNKSRC="$sourceFile" LNKTRG="$targetFile" LNKTYPE=1
}