Code: Select all
Files COMMENTS
A.bat REM Code source www.site1.com
B.bat REM Code source www.site2.com
C.bat REM Code source www.site3.com
Thanks in advance.
Moderators: Hacker, petermad, Stefan2, white
Code: Select all
Files COMMENTS
A.bat REM Code source www.site1.com
B.bat REM Code source www.site2.com
C.bat REM Code source www.site3.com
This can pretty much lead to a solution, I guess, though finding and opening each $file could be tedious (I have thousands of such files).You mean something like:
- for each line in descript.ion
---- get the file name to variable $file
---- get the comment to variable $comm
---- find and open the $file
---- add $comm to $file content and save it
If yes, then: where to add that comment line? At the very end of each batch file?
Code: Select all
FileRead, d, descript.ion
q="
Loop, parse, d, `n, `r
{
if (A_LoopField = "")
continue
line:=A_LoopField
If (SubStr(line,1,1) = q)
{
filename:=Trim(SubStr(line,1,InStr(line,q,,2)),q)
comment:=Trim(SubStr(line,InStr(line,q,,2)),q " ")
}
else
{
filename:=SubStr(line,1,InStr(line," "))
comment:=SubStr(line,InStr(line," ")+1)
}
;MsgBox % filename "`n" comment
FileAppend, `n%comment%, %filename%
}
What do I do now?---------------------------
test.ahk
---------------------------
Error at line 1.
Line Text: ileRead, d, descript.ion
Error: This line does not contain a recognized action.
The program will exit.
---------------------------
OK
---------------------------
Code: Select all
/*
- folder where script resides
|_subfolder
|_subfolder
|_subfolder
|_subfolder
*/
q="
Loop, Files, *, D
{
folder:=A_LoopFileLongPath "\"
FileRead, d, %folder%descript.ion
Loop, parse, d, `n, `r
{
if (A_LoopField = "")
continue
line:=A_LoopField
If (SubStr(line,1,1) = q)
{
filename:=folder Trim(SubStr(line,1,InStr(line,q,,2)),q)
comment:=Trim(SubStr(line,InStr(line,q,,2)),q " ")
}
else
{
filename:=folder SubStr(line,1,InStr(line," "))
comment:=SubStr(line,InStr(line," ")+1)
}
; MsgBox % filename "`n" comment
; StringReplace, comment, comment, \n, %A_Space%, All ; remove all \n replace with space
StringReplace, comment, comment, \n, `nREM%A_Space%, All ; make each \n its own REM line
FileAppend, `n%comment%, %filename% ; `n = new line so `n`n is two new lines
}
}
Code: Select all
Loop, Files, *, DR
Code: Select all
Run, test.ahk