Posted 20 December 2010 - 09:52 AM
Posted 20 December 2010 - 10:53 AM
Posted 20 December 2010 - 11:02 AM
Edited by Stephen W, 20 December 2010 - 11:41 AM.
Posted 20 December 2010 - 12:57 PM
Posted 20 December 2010 - 01:16 PM
Edited by Stephen W, 20 December 2010 - 01:25 PM.
Posted 20 December 2010 - 02:59 PM
Posted 21 December 2010 - 08:57 AM
Posted 22 December 2010 - 01:08 PM
Edited by JosiahK, 22 December 2010 - 01:09 PM.
Posted 22 December 2010 - 01:39 PM
Posted 22 December 2010 - 03:39 PM
Posted 22 December 2010 - 05:02 PM
Edited by FayB, 22 December 2010 - 05:50 PM.
Posted 22 December 2010 - 05:27 PM
Dim FN ' Name of the file. Will be passed from Batch.'
Dim ParseFile ' Entire contents of the HTML file'
Dim TS ' The string constant "_small.jpg"'
Dim FS ' Numeric location of the string TS in UnParsedFile'
Dim FQ ' Numeric Location of the quote mark " before _small.jpg.'
Dim LFS ' Last location of the end of the last TS found'
FN = "C:\Users\Josiah\Desktop\testfile.txt"
TS = "_small.jpg"
LFS = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(FN)
Set objReadFile = objFSO.OpenTextFile(FN, 1)
ParseFile = objReadFile.ReadAll
objReadFile.Close
'Scans for _small.jpg and prepends "thumbs\" to the file name'
Do
FS = Instr(LFS, ParseFile, TS)
If FS > 0 then
FQ = FS
Do
FQ = FQ - 1
Loop until mid(ParseFile, FQ, 1) = CHR(34)
If not mid(Parsefile, FQ+1,5) = "thumbs\" then
ParseFile = left(ParseFile, FQ) + "thumbs\" + right(ParseFile, len(ParseFile) - FQ)
Else
Wscript.Echo "Already Thumbs"
end if
LFS = FS + 17
end if
Loop until FS = 0
'Gets rid of the Ornj advert'
Dim DelStr
DelStr = "<p class="+chr(34)+"footnote"+chr(34)+">Photo album created with <a href="+chr(34)+"http://www.ornj.net/"+chr(34)+">Web Album Generator</a></p>"
Do
FQ = Instr(1, ParseFile, DelStr)
If FQ > 0 then
If len(ParseFile) > FQ + Len(DelStr) then
ParseFile = left(ParseFile, FQ - 1) + Right(Parsefile,len(ParseFile) - FQ - Len(DelStr) - 1)
else
ParseFile = left(ParseFile, FQ - 1)
end if
end if
Loop until FQ = 0
Set objFile = objFSO.OpenTextFile(FN, 2, True)
objFile.writeline(ParseFile)
Wscript.Echo "File Parse Complete" + vbCrLf + FNEdited by JosiahK, 22 December 2010 - 06:18 PM.
Posted 22 December 2010 - 07:26 PM
However, I do not know how to execute this command in a specific directory. Can I do this by simply creating a text document containing that syntax and naming it 'thumbs.cmd' then placing it in the relevant directory before double clicking it? Would this code automatically work within Windows 7 or would I have to install some program? That's pretty much a total guess from me but perhaps demonstrates my current understanding of this. But if I can figure out how to execute the code that creates the thumbs directory I should be able to work on the rest with more confidence.
Dim CFN ' Current Folder Name
Dim CF ' Current Folder, Object
Dim FileNames ' Array of File names in current folder.
Dim FN ' Name of the file. Will be passed from Batch.'
Dim ParseFile ' Entire contents of the HTML file'
Dim TS ' The string constant "_small.jpg"'
Dim FS ' Numeric location of the string TS in UnParsedFile'
Dim FQ ' Numeric Location of the quote mark " before _small.jpg.'
Dim LFS ' Last location of the end of the last TS found'
Dim AllFileNames ' Records all files that have been processed.'
Dim DelStr ' ornj advert to remove'
DelStr = "<p class="+chr(34)+"footnote"+chr(34)+">Photo album created with <a href="+chr(34)+"http://www.ornj.net/"+chr(34)+">Web Album Generator</a></p>"
TS = "_small.jpg"
CFN = "C:\Users\Josiah\Desktop"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set CF = objFSO.GetFolder(CFN)
Set files = CF.Files
' Outside loop, loops through files'
For each objFile In files
FN = objFile.name
' Checks for HTML extension'
If Ucase(right(FN,4)) = ".HTM" or UCASE(right(FN,5)) = ".HTML" then
LFS = 1
Set objFile = objFSO.GetFile(FN)
Set objReadFile = objFSO.OpenTextFile(FN, 1)
ParseFile = objReadFile.ReadAll
objReadFile.Close
'Scans for _small.jpg and prepends "thumbs\" to the file name'
Do
FS = Instr(LFS, ParseFile, TS)
If FS > 0 then
FQ = FS
Do
FQ = FQ - 1
Loop until mid(ParseFile, FQ, 1) = CHR(34)
If not mid(Parsefile, FQ+1,5) = "thumbs\" then
ParseFile = left(ParseFile, FQ) + "thumbs\" + right(ParseFile, len(ParseFile) - FQ)
end if
LFS = FS + 17
end if
Loop until FS = 0
'Gets rid of the Ornj advert'
Do
FQ = Instr(1, ParseFile, DelStr)
If FQ > 0 then
If len(ParseFile) > FQ + Len(DelStr) then
ParseFile = left(ParseFile, FQ - 1) + Right(Parsefile,len(ParseFile) - FQ - Len(DelStr) - 1)
else
ParseFile = left(ParseFile, FQ - 1)
end if
end if
Loop until FQ = 0
' Writes the modified file contents back into place'
Set objFile = objFSO.OpenTextFile(FN, 2, True)
objFile.writeline(ParseFile)
' Records this file in a variable as having been processed'
AllFileNames = AllFileNames + vbCrLf + FN
End if
Next
'Identifies which files have been modified'
Wscript.Echo "File Parse Complete" + vbCrLf + AllFileNames
Edited by JosiahK, 22 December 2010 - 07:28 PM.
Posted 22 December 2010 - 08:23 PM
I write code for a living, so most of my time is taken up with that, and writing code for my own projects. I gave you links to examples that show you exactly what to do; that's really the most help I can offer.
0 members, 1 guests, 0 anonymous users