I try to a automatically search for duplicate dupes files by scripts, but without extension, and select them, for delete or move;
like this exemple (in reality the list of file is more long):
video_1.avi , 20Mo
video_2.avi , 40Mo
video_2.mp4 , 5Mo
video_3.mpeg , 80Mo
video_3.mov , 50Mo
video_3.webm , 1Mo
video_3.avi , 30Mo
video_3.mp4 , 3Mo
video_4.avi , 60Mo
On this exemple I have "dupes" : video_2, and multiples dupes video_3, with different size and extensions.
I want be able to keep the most smaller files of each dupes like:
video_1.avi , 20Mo
video_2.mp4 , 5Mo
video_3.webm , 1Mo
video_4.avi , 60Mo
I create a code that work well each time:
Only to find and select dupes by name only
Please be patient: I am a coding noob...
Code: Select all
"Search Dupes Files By Name Ignore Extension And Select Them|:find"
//variables
$RESULT = "" ;
$LIST = "" ;
$COUNTER = 0 ;
//make the list only for files
$LIST = listfolder(,,1, <crlf>);
//search for dupes names
foreach( $CURRENT_ITEM , $LIST , "<crlf>")
{
foreach( $NEXT_ITEM , $LIST , "<crlf>")
{
$CURRENT_ITEM_NAME = $CURRENT_ITEM ;
$NEXT_ITEM_NAME = $NEXT_ITEM ;
//only base name no extension
$CURRENT_ITEM_NAME = getpathcomponent( $CURRENT_ITEM_NAME , "base");
$NEXT_ITEM_NAME = getpathcomponent( $NEXT_ITEM_NAME , "base");
//compare lower case names and no diacritics
$CURRENT_ITEM_NAME = recase( $CURRENT_ITEM_NAME , l );
$NEXT_ITEM_NAME = recase( $NEXT_ITEM_NAME , l );
$CURRENT_ITEM_NAME = recase( $CURRENT_ITEM_NAME , "removediacritics" );
$NEXT_ITEM_NAME = recase( $NEXT_ITEM_NAME , "removediacritics" );
//compare
if ( $CURRENT_ITEM_NAME == $NEXT_ITEM_NAME )
{
//COUNTER to compare only two at time
$COUNTER++ ;
if ( $COUNTER > 1 )
{
$RESULT = $RESULT . "" . $CURRENT_ITEM . "<crlf>" ;
}
}
};
$COUNTER = 0 ;
};
selectitems $RESULT ;
//if nothing dupes
if ( $RESULT == "" )
{
status ("No Dupes" , , "select");
}
So I tried to create another script but it doesn't work well:
in order to keep the smallest files, I try to select only the dupes bigger files
there are various problems ...
- it cannot select ALL the bigger files, when there are several dupes, (like the example video_3)
- sometimes the script completely skips some video dupes ?!! (and I don't know why ? since the first script work well, even "filesize()" always give me a size for each files)(bug?)
Code: Select all
"Search Dupes Files By Name Ignore Extension And Select The Biggest (no final, work only with 2 dupes each, skip sometimes video dupes files)|:find"
//variables
$RESULT = "" ;
$LIST = "" ;
$COUNTER = 0 ;
//make the list only for files
$LIST = listfolder(,,1, <crlf>);
//search for dupes names
foreach( $CURRENT_ITEM , $LIST , "<crlf>")
{
foreach( $NEXT_ITEM , $LIST , "<crlf>")
{
$CURRENT_ITEM_NAME = $CURRENT_ITEM ;
$NEXT_ITEM_NAME = $NEXT_ITEM ;
//only base name no extension
$CURRENT_ITEM_NAME = getpathcomponent( $CURRENT_ITEM_NAME , "base");
$NEXT_ITEM_NAME = getpathcomponent( $NEXT_ITEM_NAME , "base");
//compare lower case names no diacritics
$CURRENT_ITEM_NAME = recase( $CURRENT_ITEM_NAME , l );
$CURRENT_ITEM_NAME = recase( $CURRENT_ITEM_NAME , "removediacritics" );
$NEXT_ITEM_NAME = recase( $NEXT_ITEM_NAME , l );
$NEXT_ITEM_NAME = recase( $NEXT_ITEM_NAME , "removediacritics" );
//compare
if ( $CURRENT_ITEM_NAME == $NEXT_ITEM_NAME )
{
//COUNTER for compare only two at time
$COUNTER++ ;
if ( $COUNTER > 1 )
{
//select by size
$CURRENT_ITEM_SIZE = filesize( $CURRENT_ITEM );
$NEXT_ITEM_SIZE = filesize( $NEXT_ITEM );
if ( $CURRENT_ITEM_SIZE > $NEXT_ITEM_SIZE )
{
$RESULT = $RESULT . "" . $CURRENT_ITEM . "<crlf>" ;
}
}
}
};
$COUNTER = 0 ;
};
//for text test $RESULT
//text $RESULT ;
selectitems $RESULT ;
//if nothing dupes
if ( $RESULT == "" )
{
status ("No Dupes" , , "select");
}
Thank you so much !!!!!
Any help appreciated
XYplorer Beta Club