Ruriko Posted October 31, 2012 Posted October 31, 2012 I am having trouble of making the vbscript to read the text line by line. This is the steps the code should do:Read folder.txtOpen the file listed in folder.txtEcho the contents inside of test.txtRead folder-list.txtOpen the file listed in folder-list.txtOpen dirlist.txt and echo line by lineAn example of what folder.txt contains:C:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\test.txtC:\Documents and Settings\Administrator\Desktop\ArtistCG\[12CUT] _____ (Gakkou no Kaidan) [518382]\test.txtC:\Documents and Settings\Administrator\Desktop\ArtistCG\[2____] _____!__CD__________ [521206]\test.txtC:\Documents and Settings\Administrator\Desktop\ArtistCG\[Ability] _____________________ [514182]\test.txtAn example of what folder-list.txt contains:C:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\dirlist.txtC:\Documents and Settings\Administrator\Desktop\ArtistCG\[12CUT] _____ (Gakkou no Kaidan) [518382]\dirlist.txtC:\Documents and Settings\Administrator\Desktop\ArtistCG\[2____] _____!__CD__________ [521206]\dirlist.txtC:\Documents and Settings\Administrator\Desktop\ArtistCG\[Ability] _____________________ [514182]\dirlist.txtAn example of what each dirlist.txt containsC:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\00.jpgC:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\a_01.jpgC:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\a_02.jpgC:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\a_03.jpgAnd this is the vbscript codeOption ExplicitDim objFSO, strTextFile, strData, strLine, arrLines, aniTextFile, aniData, aniLines, meLine, objTextFile, fso, inputFileList, sFolderName, fnameDim iim1, iret, iret2, iret3, iCONST ForReading = 1strTextFile = "C:\Documents and Settings\Administrator\Desktop\ArtistCG\folder.txt"Set objFSO = CreateObject("Scripting.FileSystemObject")strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAllarrLines = Split(strData,vbCrLf)For Each strLine in arrLines strData = objFSO.OpenTextFile(strLine,ForReading).ReadAllWScript.Echo strDataaniTextFile = "C:\Documents and Settings\Administrator\Desktop\ArtistCG\folder-list.txt"Set objFSO = CreateObject("Scripting.FileSystemObject")aniData = objFSO.OpenTextFile(aniTextFile,ForReading).ReadAllaniLines = Split(aniData,vbCrLf)Set fso = CreateObject("Scripting.FileSystemObject")Set listFile = fso.OpenTextFile(aniLines).ReadAlldo while not listFile.AtEndOfStream fName = listFile.ReadLine() WScript.Echo fName LoopNextSo far I only got steps 1 to 4 working but I can't get it to read dirlist.txt. Any solutions here?
gunsmokingman Posted October 31, 2012 Posted October 31, 2012 Why are you double posting the same basic question when I provided a VBS script for you in this Thread.
Ruriko Posted October 31, 2012 Author Posted October 31, 2012 It's not the same but it's similar. The code isn't exactly the same just a bit more code added with more steps. The other thread reads 2 txt file while this one is reading 4 txt files
jaclaz Posted October 31, 2012 Posted October 31, 2012 Why are you double posting the same basic question when I provided a VBS script for you in this Thread....and on half the internet... http://www.tek-tips.com/viewthread.cfm?qid=1696999http://www.wjunction.com/53-technical-help-desk-support/156791-auto-create-txt-file-each-folder.htmlhttp://stackoverflow.com/questions/13122504/go-to-path-read-txt-file-with-vbscriptjaclaz
gunsmokingman Posted October 31, 2012 Posted October 31, 2012 The threads are similir enough for me to issue a warning for double posting, you should of ask for any further questions in the original thread.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now