Playlist Backup script = need help-check.
Posted: 14 Sep 2022 15:17
I made a script for making backup of playlists. First it checks which were modified recently, then copies to backup folder, deletes the oldest bacups of same playlists, runs the player and additional app. The strange thing is: not so seldom it happens that XY hangs upon running this script, though only simple operations are happening.(out of 10 runs there almost sure will be 1 hang)
Eventually i thought maybe i'm unintentionally creating a problem with my code, so hope smbd can check it out.
Eventually i thought maybe i'm unintentionally creating a problem with my code, so hope smbd can check it out.
Code: Select all
$PotPlayerEXE = "<xydrive>\Progs\DAUM\PotPlayer1.7.21526.x64\PotPlayerMini64.exe";
$src = gpc($PotPlayerEXE, "component", -3, 1)."\Playlist";
$bkp = gpc($PotPlayerEXE, "component", -3, 1)."\Playlist_BACKUP";
$limitCopy = "9";
$limitTime = "24";
$LinksEXE = gpc($PotPlayerEXE, "component", -3, 1)."\PotPlayerLinks.exe"; //add links app
/*
[LastBackup]
date=2022-09-14 16:19
*/
if (gettokenindex("sandbox", "<curpath>", "\") != "0") {trayballoon "Sandbox location!", "DAUM Player Backup", 35, 1; end 1==1;} //don't do false backup due to Sandbox location
if (datediff(getkey("date", "LastBackup", self("file")), now("yyyy-mm-dd hh:nn"),"h") < $limitTime){
trayballoon "Backup was done recently.", "DAUM Player Backup", 34, 1;
runq $PotPlayerEXE;
wait 10000;
runq $LinksEXE;
end 1==1;
}
$report = "";
$src_list = quicksearch("/f", $src, |, "s"); // wildcar OR /f for all files OR blank for all items(folders included)
foreach($src_item, $src_list, "|") {
$src_item_file = getpathcomponent($src_item, "file"); //file name with ext
$src_item_base = getpathcomponent($src_item, "base"); //"base", only name
//$bkp_item_chk = quicksearch($src_item_file, $bkp);
if(exists($bkp."\".$src_item_file)==0) {backupto $bkp, $src_item, 0, 1, 0,0,0,0,0;} //1: preserve dates of copied file
elseif(exists($bkp."\".$src_item_file)==1) {
if(filesize($src_item) != filesize($bkp."\".$src_item_file)){ //size compare. reacts on data add/delete
$get_date = report("{modified yyyy.mm.dd hh-nn}", $bkp."\".$src_item_file);
renameitem('*='.$get_date, $bkp."\".$src_item_file, 1); //1: Rename base (keep extension)
backupto $bkp, $src_item, 0, 1, 0,0,0,0,0; //1: preserve dates of copied file
$report = $src_item_base.<crlf>.$report;
setkey now("yyyy-mm-dd hh:nn"), "date", "LastBackup", self("file");
$bkp_list = quicksearch($src_item_base."=", $bkp, |, "s");
//echo $bkp_list;
$bkp_list_num = gettokenindex($src_item_base."=", $bkp_list, |, "wc"); //2 (return count) //w: Token has wildcards. c: Return count the occurrences.
//echo $bkp_list_num;
if($bkp_list_num > $limitCopy) {
$bkp_items= report("{Name}|", $bkp_list);
$bkp_items_sort= formatlist($bkp_items, "s", |);
$bkp_old = gettoken($bkp_items_sort, 2, "|"); //name(with ext) of oldest item
$bkp_old = $bkp."\".$bkp_old;
//echo $bkp_old;
delete 1, 0, $bkp_old;
}
}
}
}
if($report != ""){trayballoon "$report", "DAUM Player Backup", 33, 1;}
runq $PotPlayerEXE;
wait 10000;
runq $LinksEXE;