<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=13878</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13878&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: удалить устаревшие записи разговоров, 6-ую и более запись».]]></description>
		<lastBuildDate>Sun, 24 Jun 2018 06:41:46 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=126391#p126391</link>
			<description><![CDATA[<p><strong>MandarinKa02</strong> попробовал, почему-то не работает. Проверить где начинается сбой в скрипте не могу, так как для меня сложный.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sun, 24 Jun 2018 06:41:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=126391#p126391</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=126389#p126389</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sun, 24 Jun 2018 00:07:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=126389#p126389</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=126388#p126388</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Jun 2018 23:08:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=126388#p126388</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=126387#p126387</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Jun 2018 22:10:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=126387#p126387</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=126386#p126386</link>
			<description><![CDATA[<p>Появилась мысль, возможно лучше удалять с списка 6 первых попавшихся файлов с одинаковым текстом до знака @. Таким образом в списке останутся записи только после шестого разговора каждого контакта.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Jun 2018 20:21:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=126386#p126386</guid>
		</item>
		<item>
			<title><![CDATA[AHK: удалить устаревшие записи разговоров, 6-ую и более запись]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=126385#p126385</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Jun 2018 20:06:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=126385#p126385</guid>
		</item>
	</channel>
</rss>
