<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS: Поиск файлов по маске и их удаление..]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6401</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6401&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS: Поиск файлов по маске и их удаление..».]]></description>
		<lastBuildDate>Mon, 07 Nov 2011 07:04:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53303#p53303</link>
			<description><![CDATA[<p><strong>Liga010</strong>, вот Вам без лог-файла:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objFSO
Dim intErrorLevel

Dim strPathToClear
Dim strFileMask


intErrorLevel = 0

With WScript.Arguments.Named
    If .Exists(&quot;PathToClear&quot;) And .Exists(&quot;FileMask&quot;) Then
        strPathToClear = .Item(&quot;PathToClear&quot;)
        strFileMask    = .Item(&quot;FileMask&quot;)
        
        WScript.Echo strPathToClear
        WScript.Echo strFileMask
        
        Set objFSO = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
        
        If objFSO.FolderExists(strPathToClear) Then
            ClearSubFolders objFSO.GetFolder(strPathToClear), strFileMask
        Else
            intErrorLevel = 2
        End If
        
        Set objFSO = Nothing
    Else
        intErrorLevel = 1
    End If
End With

WScript.Quit intErrorLevel
&#039;=============================================================================

&#039;=============================================================================
Sub ClearSubFolders(objFolder, strMask)
    Dim objSubFolder
    
    For Each objSubFolder In objFolder.SubFolders
        ClearSubFolders objSubFolder, strMask
    Next
    
    On Error Resume Next
    objFSO.DeleteFile objFSO.BuildPath(objFolder, strMask), True
    On Error Goto 0
    
    If (objFolder.Files.Count = 0) And (objFolder.SubFolders.Count = 0) Then
        If Not (objFolder.Path = strPathToClear) Then
            objFolder.Delete True
        End If
    End If
End Sub
&#039;=============================================================================</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Mon, 07 Nov 2011 07:04:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53303#p53303</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53302#p53302</link>
			<description><![CDATA[<p>Если кого не затруднит помогите пожалуйста со скриптом, очень надо.( Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (Liga010)]]></author>
			<pubDate>Mon, 07 Nov 2011 06:19:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53302#p53302</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53290#p53290</link>
			<description><![CDATA[<p><strong>To Xameleon: </strong>Спасибо за ссылки. Я нашел такой скрипт <strong>VBS</strong>, как к нему прикрутить маску удаляемых файлов?? Я в этом полный 0, help!</p><div class="codebox"><pre><code>Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
objStartFolder = &quot;D:\Test\&quot; &#039;папка которую очищаем
arrPath =array(&quot;d:\Test\&quot;,&quot;d:\Test\test1&quot;,&quot;d:\Test\test2&quot;, &quot;d:\Test\test3&quot;) &#039;папки которые исключаем

Set objFolder = objFSO.GetFolder(objstartfolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
    If DateDiff(&quot;D&quot;, objFile.DateLastModified, Now) &gt; 10 Then &#039; проверка файлов на старость
    Log (objFolder.Path &amp; &quot;\&quot; &amp; objFile.Name &amp; &quot; - &quot; &amp; objFile.DateLastModified)
    objFile.Attributes = 0
    objFile.Delete
    End If
Next

ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
    Set objFolder = objFSO.GetFolder(subfolder.Path)
p=false
i=lbound(arrpath)
WHILE (p=false) and (i&lt;=ubound(arrpath))
    if (objfolder.path=arrpath(i) ) then
        p=true
    end if
    i=i+1
WEND
if (not p) then
&#039;    Wscript.Echo objfolder.path &amp; &quot; - &quot; &amp; &quot;udalat` mozna&quot;
    &#039; 1) проверить файлы на старость
Set colFiles = objFolder.Files
For Each objFile in colFiles
    If DateDiff(&quot;D&quot;, objFile.DateLastModified, Now) &gt; 10 Then &#039; проверка файлов на старость
    Log (objFolder.Path &amp; &quot;\&quot; &amp; objFile.Name &amp; &quot; - &quot; &amp; objFile.DateLastModified)
    objFile.Attributes = 0
    objFile.Delete
    End If
Next
    &#039; 2) проверить каталог на пустоту
If objFolder.Subfolders.Count &gt; 0 then
ShowSubFolders SubFolder
End If 
    If subFolder.Files.Count &gt; 0 AND subFolder.Subfolders.Count &gt; 0 then
&#039;    MsgBox &quot;Directory &quot; &amp; subFolder &amp; &quot;- ne pusta.&quot;
    else
    Log(subFolder.Path &amp; &quot; - &quot; &amp; subFolder.Datecreated)
    objFSO.DeleteFolder(subFolder.Path)    
    End If
End If
Next
end sub

&#039;функция для создания log-файла. он создается рядом со скриптом, имя - дата запуска скрипта.
Function Log(strLineToLog)
Const ForReading = 1, ForWriting = 2
Dim fso, f, FileLog

Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
FileLog = Left(WScript.ScriptName,(Len(WScript.ScriptName)-4)) &amp; &quot;_&quot; &amp; DatePart(&quot;yyyy&quot;,Date) &amp; &quot;_&quot; &amp; DatePart(&quot;m&quot;,Date) &amp; &quot;_&quot; &amp; DatePart(&quot;d&quot;,Date) &amp; &quot;.&quot; &amp; &quot;log&quot;
Set f = fso.OpenTextFile(FileLog, 8, True)
f.Write strLineToLog &amp; vbCrLf
f.Close
End Function</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Liga010)]]></author>
			<pubDate>Sun, 06 Nov 2011 06:13:28 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53290#p53290</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53245#p53245</link>
			<description><![CDATA[<p>Прекрасно. Я тоже самое спросил у googl-а. </p><p>Первые же 2 ссылки</p><p>1) <a href="http://forum.key.ru/viewtopic.php?f=5&amp;t=13937">КЦ КЕЙ • Просмотр темы - Подскажите скрипт для удаления файл...</a><br />2) <a href="http://forum.oszone.net/thread-175586.html">VBS/WSH/JS - [решено] WSH скрипт для удаления файлов (логика скрипта внутри)</a></p><p>Посмотрел код. Рекурсивный обход папок есть. Поиск по маске есть. Почему не подошло ?</p><p>Дальше сделал поиск по форуму запросом &quot;<strong>Поиск файлов по маске</strong>&quot; (с которого как раз было предпочтительнее начинать)</p><p>1)<a href="http://forum.script-coding.com/viewtopic.php?id=6335">WSH: Поиск файлов по маске на сервере</a><br />2)<a href="http://forum.script-coding.com/viewtopic.php?id=4306">VBS: поиск по маске в одном каталоге</a><br />3)<a href="http://forum.script-coding.com/viewtopic.php?id=4402">VBS: Удаление файлов по маске</a></p><p>И Вы утверждаете, что ничего не нашли ? )</p>]]></description>
			<author><![CDATA[null@example.com (Xameleon)]]></author>
			<pubDate>Sat, 05 Nov 2011 07:52:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53245#p53245</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53219#p53219</link>
			<description><![CDATA[<p>Такие запросы: удаление файлов по маске на VBS<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; удаление файлов в подпапках на VBS</p>]]></description>
			<author><![CDATA[null@example.com (Liga010)]]></author>
			<pubDate>Fri, 04 Nov 2011 10:25:35 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53219#p53219</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53218#p53218</link>
			<description><![CDATA[<p><strong>2 Liga010:</strong> Позвольте поинтересоваться, какие запросы вы делали в поисковике (google например) ?</p>]]></description>
			<author><![CDATA[null@example.com (Xameleon)]]></author>
			<pubDate>Fri, 04 Nov 2011 09:55:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53218#p53218</guid>
		</item>
		<item>
			<title><![CDATA[VBS: Поиск файлов по маске и их удаление..]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53215#p53215</link>
			<description><![CDATA[<p>Здравствуйте, уважаемые форумчане.<br />Мне нужна ваша помощь в написании скрипта на VBS. Задача состоит в том, чтобы скрипт искал файлы по маске в заданной директории и подпапки, затем удалял файлы и пустые подпапки, и создавал log с названиями файлов и папок которые были удалены. Порылся в инете, но дельных скритов не нашел.:( Может у кого есть уже готовый скрипт. Буду очень благодарен, за помощь!</p>]]></description>
			<author><![CDATA[null@example.com (Liga010)]]></author>
			<pubDate>Fri, 04 Nov 2011 07:17:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53215#p53215</guid>
		</item>
	</channel>
</rss>
