<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Копирование файлов с атрибутом “только для чтения“]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16292&amp;type=atom" />
	<updated>2021-04-29T20:37:30Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16292</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование файлов с атрибутом “только для чтения“]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147551#p147551" />
			<content type="html"><![CDATA[<p>Одна тема = один вопрос.</p><p>Если речь о бэкапе полного состояния папки, то список новых файлов можно получить в сравнении папки источника с папкой бэкапом. Ещё можно узнавать временные свойства файлов с помощью <a href="https://www.autohotkey.com/docs/commands/FileGetTime.htm">FileGetTime</a>.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2021-04-29T20:37:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147551#p147551</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование файлов с атрибутом “только для чтения“]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147548#p147548" />
			<content type="html"><![CDATA[<p>Надо ли будет использовать включение сохранения информации о <a href="http://markimarta.ru/windowsos/kak-opredelit-datu-poslednego-obrashheniya-k-fajlu-ili-papke-v-windows.html">дате последнего доступа к файлу</a> в Windows?</p>]]></content>
			<author>
				<name><![CDATA[peterverhovensky]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41360</uri>
			</author>
			<updated>2021-04-29T03:15:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147548#p147548</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование файлов с атрибутом “только для чтения“]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147547#p147547" />
			<content type="html"><![CDATA[<p>Выше упоминалось, что скрипт копирует новые или изменные файлы до определенной даты. А как выявить файлы созданные или измененные до этой даты, но перемещенные в папку недавно?</p>]]></content>
			<author>
				<name><![CDATA[peterverhovensky]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41360</uri>
			</author>
			<updated>2021-04-29T02:30:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147547#p147547</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование файлов с атрибутом “только для чтения“]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147516#p147516" />
			<content type="html"><![CDATA[<p>И Вам здоровья!<br />Почитайте про <a href="https://www.autohotkey.com/docs/commands/FileSetAttrib.htm">FileSetAttrib</a>.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2021-04-27T05:57:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147516#p147516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Копирование файлов с атрибутом “только для чтения“]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147515#p147515" />
			<content type="html"><![CDATA[<p>Здравствуйте, форумчане. Составил такой скрипт, предназначенный для копирования измененных с определенной даты и более новые файлы из одной папки - в папку по тому же пути, но на другом диске. То есть, если файл был на &quot;C:\Folder&quot;, то он переносится, к примеру, на &quot;D:\Folder&quot;. Думаю использовать это для быстрого бэкапа, когда бОльшая часть папки сохранена в другое место, а копировать следует только новые или измененные файлы. В результате тестов выяснилось, что файлы с атрибутом &quot;только для чтения&quot; не перезаписываются. Так понимаю, единственный выход - снимать с них этот атрибут?<br /></p><div class="codebox"><pre><code>#SingleInstance Force
SetBatchLines -1
SendMode Input
SetWorkingDir, %A_ScriptDir%

InitialFolder := &quot;C:\Folder&quot; 	;исходный путь
TargetDrive := &quot;D&quot; 		;буква диска папки-приёмника

date := &quot;2021/04/23&quot;
date := StrReplace(date, &quot;/&quot;)
;!!отчёт от текущего момента
diff -= date, Days 		; здесь diff принимает значение A_Now
;!!отчёт от начала дня
;diff := A_Year . A_MM . A_DD
;diff -= date, D
;MsgBox, % diff

;https://www.autohotkey.com/boards/viewtopic.php?p=216003#p216003
loop, %InitialFolder%\*.*, 1, 1
{
   if (SubStr(A_Now, 1, 8) - SubStr(A_LoopFileTimeModified, 1, 8) &lt; diff)
   {
      GoSub, Copy
      newFiles .= A_LoopFileFullPath &quot;`n&quot;
   }
}
MsgBox % newFiles
Return

Copy:
   FileGetAttrib, attrib, %A_LoopFileFullPath%
   IfInString, attrib, D ;если папка
   {
      Dest_Dir := RegExReplace(A_LoopFileFullPath, &quot;m`a)\w(:.*)&quot;, TargetDrive &quot;$1&quot;)
      FileGetAttrib, attrib, %Dest_Dir%\
      IfNotInString, attrib, D
         FileCreateDir, %Dest_Dir%\
   }
   Else ;если файл
   {
      Destination := RegExReplace(A_LoopFileFullPath, &quot;m`a)\w(:.*)&quot;, TargetDrive &quot;$1&quot;)
      Dest_Dir := RegExReplace(Destination, &quot;m`a)(.*)\\[^\\]*&quot;, &quot;$1&quot;)

      FileGetAttrib, attrib, %Dest_Dir%
      IfNotInString, attrib, D
         FileCreateDir, %Dest_Dir%\

      FileGetAttrib, attrib, %Dest_Dir%\
      IfNotInString, attrib, D
         FileCreateDir, %Dest_Dir%\

      FileCopy, %A_LoopFileFullPath%, %Destination%, 1 ;Перезапись
         if ErrorLevel
            MsgBox Не удалось скопировать `n&quot;%A_LoopFileFullPath%&quot;`nв `n&quot;%Destination%&quot;
   }
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[peterverhovensky]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41360</uri>
			</author>
			<updated>2021-04-27T03:30:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147515#p147515</id>
		</entry>
</feed>
