Thanks for that »Q«! You get a genuine Mr. Burns "EHHHG-zelent!"
Interesting. I've been curious about these alternate data streams for a
while now. Here's an AutoIt (
http://www.autoitscript.com) script I came
up with that will delete any ADS streams it finds in all files in any
folder and all its subfolders. It uses the technic described on the
webpage where lads.exe is distributed.
As noted, 2 freeware programs are used:
1) lads.exe from
http://www.heysoft.de/nt/ntfs-ads.htm
2) cat.exe from
http://unxutils.sourceforge.net/
Note that this script requires the BETA version of AutoIt; it will fail
with the current released version, but probably could be modified to work
if you're so inclined.
To catch wrapping, lines have been numbered. If a line doesn't start with
a number, it should be appended to the previous line. Removing the
numbers should leave you with a valid AutoIt script.
001. ; #NoTrayIcon
002. Opt("MustDeclareVars", 1)
003. Opt("TrayIconDebug", 1)
004.
005. ; Program to delete ADS (Alternate Data Streams) from files
006. ; on NTFS partitions
007. ;
008. ; two freeware programs used:
009. ;
010. ; 1) lads.exe from
http://www.heysoft.de/nt/ntfs-ads.htm
011. ; this site also explains a lot about ADS.
012. ; 2) cat.exe as part of a zip file containing many Windows
013. ; ports of Unix commands at
http://unxutils.sourceforge.net/
014. ;
015. ; if not using the compiled version of this script, be sure
016. ; to place the two exes in the same folder as the script file.
017. ;
018. ; If used, stub and stubloader are available through this thread
019. ; on AutoIt's web forums:
020. ;
http://www.autoitscript.com/forum/index.php?s=&showtopic=17380
&view=findpost&p=119727
021.
022. Global Const $lads = "lads.exe"
023. Global Const $cat = "cat.exe"
024.
025. Global $bConsoleApp = False, $vCmdLine = $CmdLine
026. Global $bExitSet = False, $sExitMsg = ''
027.
028. CheckConsole($bConsoleApp, $vCmdLine)
029.
030. Main()
031. Exit
032.
033. ;
**********************************************************************
034. Func Main()
035. Local $i, $sOut, $iColon, $sPath, $sFile, $aOut, $sTempFile,
$sPrevFile = ''
036.
037. If Not FileExists(@ScriptDir & '\' & $lads) Then
038. If @Compiled Then
039. FileInstall("lads.exe", @ScriptDir & '\')
040. Else
041. MsgBox(0, @ScriptName, 'Needed file ' & _Quote($lads) & '
not found.')
042. Return
043. EndIf
044. EndIf
045. If Not FileExists(@ScriptDir & '\' & $cat) Then
046. If @Compiled Then
047. FileInstall("cat.exe", @ScriptDir & '\')
048. Else
049. MsgBox(0, @ScriptName, 'Needed file ' & _Quote($cat) & '
not found.')
050. Return
051. EndIf
052. EndIf
053.
054. If $vCmdLine[0] > 0 Then
055. $sPath = _UnQuote($vCmdLine[1])
056. Else
057. $sPath = @ScriptDir
058. EndIf
059. Print('Scanning ' & _Quote($sPath))
060. $sOut = _RunOut(_Quote(@ScriptDir & '\' & $lads) & ' ' & _Quote
($sPath) & ' /s', @WorkingDir, @SW_HIDE)
061. $aOut = StringSplit(StringStripCR($sOut), @LF)
062. For $i = 11 To UBound($aOut) - 3 ; account for header and footer
063. ; Print($aOut[$i])
064. $iColon = StringInStr($aOut[$i],':',0,-1) ; find last
occurance of colon
065. If $iColon > 15 Then
066. $sFile = StringMid($aOut[$i],13, $iColon - 13)
067. If ($sFile <> $sPrevFile) And FileExists($sFile) Then
068. Print($sFile)
069. $sTempFile = TempFile($sFile)
070. If FileMove($sFile, $sTempFile) Then
071. _RunDOS(_Quote(@ScriptDir & '\' & $cat) & ' ' &
_Quote($sTempFile) & ' >' & _Quote($sFile))
072. FileDelete($sTempFile)
073. Else
074. Print('Rename failed!: ' & _Quote($sFile) & ' to ' &
_Quote($sTempFile))
075. EndIf
076. $sPrevFile = $sFile
077. EndIf
078. EndIf
079. Next
080. EndFunc ;==>Main
081.
082. ;
**********************************************************************
083. ; Generate a name for a temporary file, making sure the file does
084. ; not already exist.
085. ;
**********************************************************************
086. Func TempFile($sFile)
087. Local $sTempName
088. Do
089. $sTempName = "~"
090. While StringLen($sTempName) < 3
091. $sTempName = $sTempName & Chr(Round(Random(97, 122), 0))
092. Wend
093. $sTempName = $sFile & "." & $sTempName
094. Until Not FileExists($sTempName)
095. Return ($sTempName)
096. EndFunc ;==>_TempFile
097.
098. ;
**********************************************************************
099. Func Print($sMsg)
100. If $bConsoleApp Then
101. ConsoleWrite(StringStripWS($sMsg, 3) & @LF)
102. Else
103. If Not $bExitSet Then
104. Opt("OnExitFunc", "PrintOnExit")
105. EndIf
106. $sExitMsg &= @LF & StringStripWS($sMsg, 3)
107. If @TrayIconVisible Then TrayTip(@ScriptName, $sMsg, 1, 1)
108. EndIf
109. EndFunc
110.
111. Func PrintOnExit()
112. If StringLen($sExitMsg) > 1 Then
113. MsgBox(0, @ScriptName, StringTrimLeft($sExitMsg, 1), 10)
114. EndIf
115. EndFunc
116.
117. ;
**********************************************************************
118. Func CheckConsole(ByRef $bConsoleApp, ByRef $vCmdLine)
119. Local $i
120. $bConsoleApp = False
121. If $vCmdLine[0] > 0 Then
122. If $vCmdLine[1] = '/console' Then
123. $bConsoleApp = True
124. $vCmdLine[0] -= 1
125. For $i = 1 To $vCmdLine[0]
126. $vCmdLine[$i] = $vCmdLine[$i+1]
127. Next
128. EndIf
129. EndIf
130. EndFunc
131.
132. ;
**********************************************************************
133. Func _Quote($sTheString, $sQuoteChar = '"')
134. Return ($sQuoteChar & $sTheString & $sQuoteChar)
135. EndFunc
136.
137. ;
**********************************************************************
138. ; Run a "DOS" command without showing any window.
139. ;
**********************************************************************
140. Func _RunDOS($sCommand)
141. Return RunWait(@ComSpec & ' /C' & $sCommand, @WorkingDir,
@SW_HIDE)
142. EndFunc ;==>_RunDOS
143.
144. ;
**********************************************************************
145. ; Run a command without showing any window.
146. ; Returns the output of the command.
147. ;
**********************************************************************
148. Func _RunOut($sCommand, $sWorkDir = @WorkingDir, $iShowMode =
@SW_HIDE)
149. Local $sResult = '', $iPID = Run($sCommand, $sWorkDir,
$iShowMode, 2)
150. While Not
@error
151. $sResult &= StdoutRead($iPID)
152. Wend
153. Return $sResult
154. EndFunc;==>_RunOut
155.
156. ;
**********************************************************************
157. Func _UnQuote($sTheString, $sQuoteChar = '"')
158. If (StringLeft($sTheString, 1) = $sQuoteChar) And (StringRight
($sTheString, 1) = $sQuoteChar) Then
159. Return StringMid($sTheString, 2, (StringLen($sTheString) - 2))
160. Else
161. Return $sTheString
162. EndIf
163. EndFunc
As always with things like this, use at your own risk, yada yada yada,
don't blame me, yada yada yada. All I know is it works for me.
HTH