<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13878&amp;type=atom" />
	<updated>2018-06-24T06:41:46Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13878</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126391#p126391" />
			<content type="html"><![CDATA[<p><strong>MandarinKa02</strong> попробовал, почему-то не работает. Проверить где начинается сбой в скрипте не могу, так как для меня сложный.</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2018-06-24T06:41:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126391#p126391</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126389#p126389" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
path:=A_ScriptDir
files:=[]
Loop, % path &quot;\*.amr&quot;, 0,0
{
	files[A_Index]:=A_LoopFileName
}

for i in files {
	function(&quot;new&quot;,files[i])
}



Loop, % path &quot;\*.amr&quot;, 0,0
{
	if (!function(&quot;check&quot;,A_LoopFileName)) {
		FileDelete, % A_LoopFileFullPath
	}
}
return


F5::Reload

function(act,value=0,value2=0) {
	static list:=[], max:=5

	if (act=&quot;new&quot;) {
		num :=RegExReplace(value, &quot;.*@(.*)_.*&quot;,&quot;$1&quot;)
		date:=RegExReplace(value, &quot;.*@.*_(.*)&quot;,&quot;$1&quot;)
		if (!list[num][&quot;total&quot;])
			list[num]:=[],list[num][&quot;total&quot;]:=1, list[num][1]:=date
		else if(list[num][&quot;total&quot;]=max)
			function(&quot;add&quot;,num,date)
		else list[num][&quot;total&quot;]+=1,i:=list[num][&quot;total&quot;],list[num][i]:=date
	} else if(act=&quot;add&quot;) {
		num:=value,date:=value2
		for i,value in list[value] {
			if(i=&quot;total&quot;)
				Continue
			if (IsLatest(date,value)) {
				list[num][i]:=date
				function(&quot;add&quot;,num,value)
				return 1
			}
		} return 0
	} else if(act=&quot;check&quot;) {
		num :=RegExReplace(value, &quot;.*@(.*)_.*&quot;,&quot;$1&quot;)
		date:=RegExReplace(value, &quot;.*@.*_(.*)&quot;,&quot;$1&quot;)
		for i,value in list[num] {
			if(list[num][i]=date)
				return 1
		} return 0
	}
}



IsLatest(_1th,_2nd) {
	_1th:=SplitDate(_1th)
	_2nd:=SplitDate(_2nd)
	if(_1th[&quot;year&quot;]&lt;_2nd[&quot;year&quot;])
		return 0
	else if(_1th[&quot;year&quot;]&gt;_2nd[&quot;year&quot;])
		return 1

	if(_1th[&quot;month&quot;]&lt;_2nd[&quot;month&quot;])
		return 0
	else if(_1th[&quot;month&quot;]&gt;_2nd[&quot;month&quot;])
		return 2

	if(_1th[&quot;day&quot;]&lt;_2nd[&quot;day&quot;])
		return 0
	else if(_1th[&quot;day&quot;]&gt;_2nd[&quot;day&quot;])
		return 2
	
	if(_1th[&quot;hour&quot;]&lt;_2nd[&quot;hour&quot;])
		return 0
	else if(_1th[&quot;hour&quot;]&gt;_2nd[&quot;hour&quot;])
		return 2
	
	if(_1th[&quot;min&quot;]&lt;_2nd[&quot;min&quot;])
		return 0
	else if(_1th[&quot;min&quot;]&gt;_2nd[&quot;min&quot;])
		return 2

	if(_1th[&quot;sec&quot;]&lt;_2nd[&quot;sec&quot;])
		return 0
	return 6
}



SplitDate(date) {
	var:=&quot;&quot;,out:=[]
	loop,parse,date
	{
		if(!StrLen(var)&amp;&amp;!A_LoopField)
			Continue
		var.=A_LoopField
		if(A_Index=4)
			out[&quot;year&quot;]:=var,var:=&quot;&quot;
		else if(A_Index=6)
			out[&quot;month&quot;]:=var,var:=&quot;&quot;
		else if(A_Index=8)
			out[&quot;day&quot;]:=var,var:=&quot;&quot;
		else if(A_Index=10)
			out[&quot;hour&quot;]:=var,var:=&quot;&quot;
		else if(A_Index=12)
			out[&quot;min&quot;]:=var,var:=&quot;&quot;
		else if(A_Index=14)
			out[&quot;sec&quot;]:=var,var:=&quot;&quot;
	} return out
	;msgbox % date &quot;`n&quot; out[&quot;year&quot;] &quot;-&quot; out[&quot;month&quot;] &quot;-&quot; out[&quot;day&quot;] &quot;`n&quot; out[&quot;hour&quot;] &quot;:&quot; out[&quot;min&quot;] &quot;:&quot; out[&quot;sec&quot;]
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[MandarinKa02]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34409</uri>
			</author>
			<updated>2018-06-24T00:07:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126389#p126389</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126388#p126388" />
			<content type="html"><![CDATA[<p>Рабочий вариант.<br /></p><div class="codebox"><pre><code>FileList =
Loop, Files, %A_WorkingDir%\*.amr, F
FileList = %FileList%%A_LoopFileFullPath%`n
Sort, FileList, r
Loop, Parse, FileList, `n
{
if A_LoopField =
continue
old := subpat1
RegExMatch(A_LoopField, &quot;(.*)_&quot;, SubPat)
If InStr(SubPat1, old)
{
same += 1
}
Else
{
same = 0
}
if (same &gt; 5)
{
FileDelete, %A_LoopField%
FileAppend, `n %A_LoopField%, %A_WorkingDir%\deleted.txt
}
}</code></pre></div><p>На 500мб файлов почистило - хорошо.</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2018-06-23T23:08:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126388#p126388</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126387#p126387" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>FileList =
Loop, Files, D:\Downloads_after_15.08.17\фотки\много\record\nomedia\*.amr, F  ; Include Files and Directories
    FileList = %FileList%`t%A_LoopFileName%`n
Sort, FileList, r  ; Sort by date.
;FoundPos := RegExMatch(&quot;abcX@YZ123&quot;, &quot;(.*)@&quot;, SubPat)
;MsgBox, %SubPat1%
MsgBox, %FileList%
Loop, Parse, FileList, `n
{
    if A_LoopField =  ; Omit the last linefeed (blank item) at the end of the list.
        continue
    ;StringSplit, FileItem, A_LoopField, %A_Tab%  ; Split into two parts at the tab char.
old := subpat1
	RegExMatch(A_LoopField, &quot;(.*)_&quot;, SubPat)
;MsgBox, %SubPat1% %old%
If InStr(SubPat1, old)
{
	same += 1
 ;MsgBox, %same%
}
Else
{
	same = 0
  ;MsgBox, The string was not found.
}
if (same &gt; 5)
{
	
	FileAppend, `n %A_LoopField%, D:\Downloads_after_15.08.17\фотки\много\record\nomedia\Test.txt
   
}
   ; MsgBox, 4,, %FileList% The next file (modified at %FileItem1%) is:`n%FileItem2%`n`nContinue?
    ;IfMsgBox, No
    ;    break
}
</code></pre></div><p>Осталось придумать как удалить.</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2018-06-23T22:10:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126387#p126387</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126386#p126386" />
			<content type="html"><![CDATA[<p>Появилась мысль, возможно лучше удалять с списка 6 первых попавшихся файлов с одинаковым текстом до знака @. Таким образом в списке останутся записи только после шестого разговора каждого контакта.</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2018-06-23T20:21:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126386#p126386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126385#p126385" />
			<content type="html"><![CDATA[<p>На телефоне идёт постоянная запись разговоров, накопилось более 3000 amr файлов. Из-за такого количества программа для прослушивания разговоров медленно работает. Идея - удалить устаревшие разговоры каждого абонента и оставить 6 самых новых.</p><br /><p>Файлы имеют такой патерн названий, 5** 27 До 3 Или После 5 Роутер@+380 95 *** *364_20180618182637.amr где до&nbsp; _&nbsp; всегда идёт имя и номер абонента.</p><p>Рабочий вариант.<br /></p><div class="codebox"><pre><code>FileList =
Loop, Files, %A_WorkingDir%\*.amr, F
FileList = %FileList%%A_LoopFileFullPath%`n
Sort, FileList, r
Loop, Parse, FileList, `n
{
if A_LoopField =
continue
old := subpat1
RegExMatch(A_LoopField, &quot;(.*)_&quot;, SubPat)
If InStr(SubPat1, old)
{
same += 1
}
Else
{
same = 0
}
if (same &gt; 5)
{
FileDelete, %A_LoopField%
FileAppend, `n %A_LoopField%, %A_WorkingDir%\deleted.txt
}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2018-06-23T20:06:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126385#p126385</id>
		</entry>
</feed>
