<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=17825</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17825&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Удаление файлов в архиве, которые уже есть в другом».]]></description>
		<lastBuildDate>Wed, 14 Jun 2023 18:40:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158544#p158544</link>
			<description><![CDATA[<p>На C# .NET вышло:<br /></p><div class="codebox"><pre><code>zipArchivePath := A_Desktop . &quot;\test.zip&quot;
fileToDelete := &quot;test.txt&quot;

c# =
(
    using System;
    using System.IO;
    using System.IO.Compression;

    class Program
    {
        public void DeleteArchiveEntry()
        {
            string zipPath = @&quot;%zipArchivePath%&quot;;
            string fileToDelete = @&quot;%fileToDelete%&quot;;

            using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Update))
            {
                ZipArchiveEntry entry = archive.GetEntry(fileToDelete);

                if (entry != null)
                {
                    entry.Delete();
                }
            }
        }
    }
)

asm := CLR_CompileC#(c#, &quot;System.dll | System.IO.Compression.dll | System.IO.Compression.FileSystem.dll&quot;)
obj := CLR_CreateObject(asm, &quot;Program&quot;)
obj.DeleteArchiveEntry()


; ==========================================================
;                  .NET Framework Interop
; https://www.autohotkey.com/boards/viewtopic.php?f=6&amp;t=4633
; ==========================================================
;
;   Author:     Lexikos
;   Version:    1.2
;   Requires:	AutoHotkey_L v1.0.96+
;

CLR_LoadLibrary(AssemblyName, AppDomain=0)
{
	if !AppDomain
		AppDomain := CLR_GetDefaultDomain()
	e := ComObjError(0)
	Loop 1 {
		if assembly := AppDomain.Load_2(AssemblyName)
			break
		static null := ComObject(13,0)
		args := ComObjArray(0xC, 1),  args[0] := AssemblyName
		typeofAssembly := AppDomain.GetType().Assembly.GetType()
		if assembly := typeofAssembly.InvokeMember_3(&quot;LoadWithPartialName&quot;, 0x158, null, null, args)
			break
		if assembly := typeofAssembly.InvokeMember_3(&quot;LoadFrom&quot;, 0x158, null, null, args)
			break
	}
	ComObjError(e)
	return assembly
}

CLR_CreateObject(Assembly, TypeName, Args*)
{
	if !(argCount := Args.MaxIndex())
		return Assembly.CreateInstance_2(TypeName, true)
	
	vargs := ComObjArray(0xC, argCount)
	Loop % argCount
		vargs[A_Index-1] := Args[A_Index]
	
	static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
	
	return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
}

CLR_CompileC#(Code, References=&quot;&quot;, AppDomain=0, FileName=&quot;&quot;, CompilerOptions=&quot;&quot;)
{
	return CLR_CompileAssembly(Code, References, &quot;System&quot;, &quot;Microsoft.CSharp.CSharpCodeProvider&quot;, AppDomain, FileName, CompilerOptions)
}

CLR_CompileVB(Code, References=&quot;&quot;, AppDomain=0, FileName=&quot;&quot;, CompilerOptions=&quot;&quot;)
{
	return CLR_CompileAssembly(Code, References, &quot;System&quot;, &quot;Microsoft.VisualBasic.VBCodeProvider&quot;, AppDomain, FileName, CompilerOptions)
}

CLR_StartDomain(ByRef AppDomain, BaseDirectory=&quot;&quot;)
{
	static null := ComObject(13,0)
	args := ComObjArray(0xC, 5), args[0] := &quot;&quot;, args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
	AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3(&quot;CreateDomain&quot;, 0x158, null, null, args)
	return A_LastError &gt;= 0
}

CLR_StopDomain(ByRef AppDomain)
{	; ICorRuntimeHost::UnloadDomain
	DllCall(&quot;SetLastError&quot;, &quot;uint&quot;, hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), &quot;ptr&quot;, RtHst, &quot;ptr&quot;, ComObjValue(AppDomain))), AppDomain := &quot;&quot;
	return hr &gt;= 0
}

; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
CLR_Start(Version=&quot;&quot;) ; returns ICorRuntimeHost*
{
	static RtHst := 0
	; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
	; return RtHst ? RtHst : (RtHst:=COM_CreateObject(&quot;CLRMetaData.CorRuntimeHost&quot;,&quot;{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}&quot;), DllCall(NumGet(NumGet(RtHst+0)+40),&quot;uint&quot;,RtHst))
	if RtHst
		return RtHst
	EnvGet SystemRoot, SystemRoot
	if Version =
		Loop % SystemRoot &quot;\Microsoft.NET\Framework&quot; (A_PtrSize=8?&quot;64&quot;:&quot;&quot;) &quot;\*&quot;, 2
			if (FileExist(A_LoopFileFullPath &quot;\mscorlib.dll&quot;) &amp;&amp; A_LoopFileName &gt; Version)
				Version := A_LoopFileName
	if DllCall(&quot;mscoree\CorBindToRuntimeEx&quot;, &quot;wstr&quot;, Version, &quot;ptr&quot;, 0, &quot;uint&quot;, 0
	, &quot;ptr&quot;, CLR_GUID(CLSID_CorRuntimeHost, &quot;{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}&quot;)
	, &quot;ptr&quot;, CLR_GUID(IID_ICorRuntimeHost,  &quot;{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}&quot;)
	, &quot;ptr*&quot;, RtHst) &gt;= 0
		DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), &quot;ptr&quot;, RtHst) ; Start
	return RtHst
}

;
; INTERNAL FUNCTIONS
;

CLR_GetDefaultDomain()
{
	static defaultDomain := 0
	if !defaultDomain
	{	; ICorRuntimeHost::GetDefaultDomain
		if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), &quot;ptr&quot;, RtHst, &quot;ptr*&quot;, p:=0) &gt;= 0
			defaultDomain := ComObject(p), ObjRelease(p)
	}
	return defaultDomain
}

CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName=&quot;&quot;, CompilerOptions=&quot;&quot;)
{
	if !AppDomain
		AppDomain := CLR_GetDefaultDomain()
	
	if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
	|| !(codeProvider := asmProvider.CreateInstance(ProviderType))
	|| !(codeCompiler := codeProvider.CreateCompiler())
		return 0

	if !(asmSystem := (ProviderAssembly=&quot;System&quot;) ? asmProvider : CLR_LoadLibrary(&quot;System&quot;, AppDomain))
		return 0
	
	; Convert | delimited list of references into an array.
	StringSplit, Refs, References, |, %A_Space%%A_Tab%
	aRefs := ComObjArray(8, Refs0)
	Loop % Refs0
		aRefs[A_Index-1] := Refs%A_Index%
	
	; Set parameters for compiler.
	prms := CLR_CreateObject(asmSystem, &quot;System.CodeDom.Compiler.CompilerParameters&quot;, aRefs)
	, prms.OutputAssembly          := FileName
	, prms.GenerateInMemory        := FileName=&quot;&quot;
	, prms.GenerateExecutable      := SubStr(FileName,-3)=&quot;.exe&quot;
	, prms.CompilerOptions         := CompilerOptions
	, prms.IncludeDebugInformation := true
	
	; Compile!
	compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
	
	if error_count := (errors := compilerRes.Errors).Count
	{
		error_text := &quot;&quot;
		Loop % error_count
			error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? &quot;Warning &quot; : &quot;Error &quot;) . e.ErrorNumber &quot; on line &quot; e.Line &quot;: &quot; e.ErrorText &quot;`n`n&quot;
		MsgBox, 16, Compilation Failed, %error_text%
		return 0
	}
	; Success. Return Assembly object or path.
	return compilerRes[FileName=&quot;&quot; ? &quot;CompiledAssembly&quot; : &quot;PathToAssembly&quot;]
}

CLR_GUID(ByRef GUID, sGUID)
{
	VarSetCapacity(GUID, 16, 0)
	return DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;wstr&quot;, sGUID, &quot;ptr&quot;, &amp;GUID) &gt;= 0 ? &amp;GUID : &quot;&quot;
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 14 Jun 2023 18:40:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158544#p158544</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158543#p158543</link>
			<description><![CDATA[<p>Я так и представлял, но думал, что может прямое решение найдётся, но пока не нашёл, кроме InvokeVerb, но там окно диалога подтверждения выскакивает.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 14 Jun 2023 17:41:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158543#p158543</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158542#p158542</link>
			<description><![CDATA[<p>А не проще через MoveHere перемещать во временную директорию, после чего удалять ее?<br /><a href="https://learn.microsoft.com/en-us/windows/win32/shell/folder-movehere">https://learn.microsoft.com/en-us/windo … r-movehere</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 14 Jun 2023 16:40:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158542#p158542</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158540#p158540</link>
			<description><![CDATA[<p>Скорее всего проблематично, проще новый архив создать уже с нужным набором файлов.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 14 Jun 2023 15:04:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158540#p158540</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158537#p158537</link>
			<description><![CDATA[<p>Получился вот такой скрипт:<br /></p><div class="codebox"><pre><code>#MaxMem
#NoEnv

FileDelete, %A_scriptdir%\AllSubFldList.ahk
sleep, 200
FileMove, %A_scriptdir%\OLD\*.rar, %A_scriptdir%\OLD\*.zip ;
Sleep, 100
FileMove, %A_scriptdir%\OLD\*.zip, %A_scriptdir%\OLD\2.zip ;
Sleep, 100

FileMove, %A_scriptdir%\NEW\*.rar, %A_scriptdir%\NEW\*.zip ;
Sleep, 100
FileMove, %A_scriptdir%\NEW\*.zip, %A_scriptdir%\NEW\3.zip ;
Sleep, 100

ArcPath = %A_scriptdir%\OLD\2.zip
OutPath = %A_scriptdir%\OLD

Shell := ComObjCreate(&quot;Shell.Application&quot;)
Items := Shell.NameSpace(ArcPath).Items
Items.Filter(73952, &quot;*&quot;)
Shell.NameSpace(OutPath).CopyHere(Items, 16)

sleep, 2000

SetBatchLines, -1

folder := A_ScriptDir . &quot;\OLD&quot;
Loop, %folder%\*.pdf, 0
   list .= &quot;FileDelete, %A_scriptdir%\3\&quot; A_LoopFileName &quot;`n&quot;
FileAppend, % list, %A_scriptdir%\AllSubFldList.ahk
list =


sleep, 1500

Run, AllSubFldList.ahk
Sleep, 500
FileDelete, %A_scriptdir%\AllSubFldList.ahk

return</code></pre></div><p>Но, он удаляет файлы из папки.<br />Никак не могу найти как удалять файлы из ZIP архива.<br />Это вообще возможно?</p>]]></description>
			<author><![CDATA[null@example.com (D@rkSIDeR008)]]></author>
			<pubDate>Wed, 14 Jun 2023 05:34:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158537#p158537</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158519#p158519</link>
			<description><![CDATA[<p>Опять у вас точки пропали почему-то.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 12 Jun 2023 11:08:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158519#p158519</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158518#p158518</link>
			<description><![CDATA[<p>Ошибку понял.</p><div class="codebox"><pre><code>#MaxMem
#NoEnv
SetBatchLines, -1

folder := A_ScriptDir . &quot;\2&quot;
Loop, %folder%\*.*, 0
   list .= A_LoopFileName &quot;`n&quot;
FileAppend, % list, %A_scriptdir%\AllSubFldList.txt
list =
return</code></pre></div><p>В LOOP стоял параметр &quot;2&quot; он оказывается показывает только папки, выставил 0, все заработало.<br />Теперь, не могли бы подсказать как в строчку:<br /></p><div class="codebox"><pre><code>list .= A_LoopFileName &quot;`n&quot;</code></pre></div><p>вставить еще своего текста, только не обычного, потому что если я просто пишу слово оно вставляется, а я хочу вписать туда директорию, и так как в ней присутствуют запятая и слеш скрипт видимо их распознает не как текст.<br />Возможно ли как то обернуть текст и потом туда вставить, может в кавычках или например:<br /></p><div class="codebox"><pre><code>text1 .= FileDelete, 3/
list . =% text1, A_LoopFileName &quot;`n&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (D@rkSIDeR008)]]></author>
			<pubDate>Mon, 12 Jun 2023 09:25:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158518#p158518</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158517#p158517</link>
			<description><![CDATA[<p>Zip файлы Windows понимает, как папки.</p><div class="quotebox"><cite>D@rkSIDeR008 пишет:</cite><blockquote><p>выдает только список папок, но не файлов</p></blockquote></div><p>Смотрите в справку по Loop, files.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 12 Jun 2023 08:02:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158517#p158517</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158516#p158516</link>
			<description><![CDATA[<p>Нашел тут же на форме скрипт<br /></p><div class="codebox"><pre><code>#MaxMem
#NoEnv
SetBatchLines, -1

folder := A_ScriptDir . &quot;\2&quot;
Loop, %folder%\*.*, 2
   list .= A_LoopFileLongPath &quot;`n&quot;
FileAppend, % list, %A_scriptdir%\AllSubFldList.txt
list =
return</code></pre></div><p>Но он почему то, выдает только список папок, но не файлов.</p>]]></description>
			<author><![CDATA[null@example.com (D@rkSIDeR008)]]></author>
			<pubDate>Mon, 12 Jun 2023 03:55:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158516#p158516</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158515#p158515</link>
			<description><![CDATA[<p>А если они будут zip? Или если не получается это сделать в архиве, можно разархивировать в папки, будет хоть какая то автоматика.<br /> Можно как то создать список файлов в папке?</p>]]></description>
			<author><![CDATA[null@example.com (D@rkSIDeR008)]]></author>
			<pubDate>Mon, 12 Jun 2023 03:33:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158515#p158515</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158505#p158505</link>
			<description><![CDATA[<p>Насколько я знаю, Windows не поддерживает rar-архивы нативно, нужны сторонние библиотеки.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 10 Jun 2023 17:23:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158505#p158505</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158504#p158504</link>
			<description><![CDATA[<p>Мысль была сделать список файлов из первого архива, и удалить их из второго, но знаний не хватает.</p>]]></description>
			<author><![CDATA[null@example.com (D@rkSIDeR008)]]></author>
			<pubDate>Sat, 10 Jun 2023 15:58:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158504#p158504</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158503#p158503</link>
			<description><![CDATA[<p>Архивы формата *.rar.</p>]]></description>
			<author><![CDATA[null@example.com (D@rkSIDeR008)]]></author>
			<pubDate>Sat, 10 Jun 2023 15:57:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158503#p158503</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158502#p158502</link>
			<description><![CDATA[<p>Ещё добавлю, что нужно уточнить что за архивы (.zip, .rar и т.д.).</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Sat, 10 Jun 2023 13:50:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158502#p158502</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Удаление файлов в архиве, которые уже есть в другом]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=158501#p158501</link>
			<description><![CDATA[<p><strong>D@rkSIDeR008</strong>, ознакомьтесь, пожалуйста, с <a href="https://forum.script-coding.com/misc.php?action=rules">Правилами</a>, отредактируйте свой пост. Обратите внимание на <a href="https://forum.script-coding.com/misc.php?action=rules#literacy">точки</a> в конце предложений.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 10 Jun 2023 11:18:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=158501#p158501</guid>
		</item>
	</channel>
</rss>
