/ Published in: Other
Backup dei files *.qvd e "svecchiamento" automatico per avere solo N backup in linea
Expand |
Embed | Plain Text
Salve a tutti condivido qui il codice commentato, che possa essere di aiuto per chi necessita di interfacciare il mondo scripting Windows in maniera efficace. SET ThousandSep=','; SET DecimalSep='.'; SET MoneyThousandSep=','; SET MoneyDecimalSep='.'; SET MoneyFormat='$#,##0.00;($#,##0.00)'; SET TimeFormat='hh:mm:ss'; SET DateFormat='DD-MM-YYYY'; SET TimestampFormat='DD-MM-YYYY hh:mm:ss[.fff]'; SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec'; SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun'; //reperimento timestamp let adesso=now() ; trace $(adesso); let adesso= trim(Replace ('$(adesso)',':',' ') ); let adesso= trim(Replace ('$(adesso)',' ','-') ); trace $(adesso); //copia del file QVD let command='cmd.exe /C copy stdp.qvd stdp.qvd.$(adesso).QBK>>bk_inps_stdp.log'; trace $(command); execute $(command); // determinazione svecchiamento //lista dei backup su CMD tramite comando DIR execute cmd.exe /C dir /O-D /TC *.qbk >listdir.csv; // conta dei backup escludendo le righe inutili quantiso: LOAD count(*)-4 as quantifile FROM [C:\Users\buffaale\Documents\Lavoro\Progetti\INPS_NEW\STDP\T&T\__T&T_Alessia\Oggetti STDP\qv\sviluppo_versione_DATOSSPARZ\listdir.csv] (txt, codepage is 1252, embedded labels, delimiter is spaces, msq); let numfiles=peek ('quantifile', 0 , quantiso ) ; trace $(numfiles); //caricamento lista dei backup eseguiti filesalvati: LOAD Volume, in, drive, C as nomefile, is, PC, COE FROM [C:\Users\buffaale\Documents\Lavoro\Progetti\INPS_NEW\STDP\T&T\__T&T_Alessia\Oggetti STDP\qv\sviluppo_versione_DATOSSPARZ\listdir.csv] (txt, codepage is 1252, embedded labels, delimiter is spaces, msq); // lista delle occorrenze files candidate alla cancellazione, tramite un ciclo FOR/NEXT for i=-$(numfiles)+1 to 0 let filetocanc=peek ('nomefile', i , filesalvati ) ; trace $(filetocanc); //cancellazione dell'occorrenza trovata idonea let command='cmd.exe /C del $(filetocanc)>>bk_inps_stdp.log'; execute $(command); next i; //
You need to login to post a comment.
