Similarity Forum

General Category => Wishlist => Topic started by: Hoveizavi on August 12, 2017, 10:42:09

Title: How to create Symbolic link (Softlink or Shortcut) before deleting Marked items?
Post by: Hoveizavi on August 12, 2017, 10:42:09
How to create Symbolic link (Softlink or Shortcut) from "Unmarked" item of a Non-duplicate file before deleting one's duplicates that are "Marked"? (Of course into their own folders)
Is there a Script to do this? This is very functional (Especially for audio files)
Title: Re: How to create Symbolic link (Softlink or Shortcut) before deleting Marked items?
Post by: Admin on August 28, 2017, 22:33:06
Similarity has no functions to make symbolic links. We think about this feature in future.
Title: Re: How to create Symbolic link (Softlink or Shortcut) before deleting Marked items?
Post by: cedricpah on November 25, 2017, 16:15:22
Hi,

I had the same need, and I think you can addapt my script.
After playing the script, look at the log file and just keep what you need in the log file to make a batch command lines. And play that batch file.

For information, this script compare analysis properties of files, and if equals, it logs the needed command line to delete one of them and make a hard link to the second one.
Enjoy.
Code: [Select]
/*
Author: Cedric
Description: Mark all files that have same analysis
*/

// unmark all files
results.audio.unmark();

var dups = results.audio.dups;
for (var idx = 0; idx < dups.length; ++idx) {
    // skip counter-pair (1-2 and 2-1), process pair only once
if (dups[idx].item1.path > dups[idx].item2.path) continue;
try {
    if (dups[idx].item1.analysis.duration  == dups[idx].item2.analysis.duration && dups[idx].item1.analysis.samplerate== dups[idx].item2.analysis.samplerate && dups[idx].item1.analysis.datatype  == dups[idx].item2.analysis.datatype && dups[idx].item1.analysis.channels  == dups[idx].item2.analysis.channels && dups[idx].item1.analysis.format    == dups[idx].item2.analysis.format && dups[idx].item1.analysis.clips     == dups[idx].item2.analysis.clips && dups[idx].item1.analysis.silence   == dups[idx].item2.analysis.silence && dups[idx].item1.analysis.absMean   == dups[idx].item2.analysis.absMean && dups[idx].item1.analysis.minStep   == dups[idx].item2.analysis.minStep && dups[idx].item1.analysis.absMax    == dups[idx].item2.analysis.absMax && dups[idx].item1.analysis.maxFreq   == dups[idx].item2.analysis.maxFreq && dups[idx].item1.analysis.clicks    == dups[idx].item2.analysis.clicks && dups[idx].item1.analysis.rating    == dups[idx].item2.analysis.rating) log('delete "'+ dups[idx].item2 + '" mklink /h "' + dups[idx].item2 + '" "' + dups[idx].item1+ '"' );
}
catch (e) {
log('Exception ' + e);
}
}
Title: Re: How to create Symbolic link (Softlink or Shortcut) before deleting Marked items?
Post by: cedricpah on November 26, 2017, 10:42:07
Hi,

More simple this script will prepare delete and mklink command for marked files. But there will be dups so with excel you need to clean the list. That's why I log precise, because I will sort result for each "to deleted" file by precise desc. After, just keep the upper value (for E4 cell just use this formula =SI(NB.SI(C$1:C3;C4)=0;C4;"") (sorry formula in french excel relase). And with this script it can keep the filename with extension of hard linked file.
Code: [Select]
/*
Author: Cedric
Description: prepare mklink for marked files
*/
var dups = results.audio.dups;
for (var idx = 0; idx < dups.length; ++idx) {
if (!(dups[idx].item1.marked == true && dups[idx].item2.marked == false)) continue;
try {
var scores = audio.calculate(dups[idx].item1, dups[idx].item2, 'precise');
log(scores['precise'] + ';delete "'+ dups[idx].item1 + '";mklink /h "' + dups[idx].item1.toString().replace(/\..+$/, '') + dups[idx].item2.toString().split('.').pop()  + '" "' + dups[idx].item2+ '"' );
}
catch (e) {
log('Exception ' + e);
}
}