AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading C:\ and file the same time

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Seclinix



Joined: 26 Sep 2006
Posts: 175
Location: In a House, On my a55

PostPosted: Wed Apr 04, 2007 9:57 pm    Post subject: Reading C:\ and file the same time Reply with quote

any idea's..... i want to read a file from C:/ and while it is reading that file i want to read a txt file and try to match it with a line in the text file with the same name

Code:

Loop, C:\*.*,,1
{
     FileAppend, %A_LoopFileFullPath%`n, %A_DesktopCommon%
     Loop, Read, %A_DesktopCommon%\vir.txt
     {
            If %A_LoopFileName% = %A_LoopReadLine%
            {
                   Msgbox, match
            }
            Else
            If %A_LoopFileName% <> %A_LoopReadLine%
            {
             
            }
       }
}
Return
[/code]
_________________
You can download Runescape Macro's From
My Website
Virus codes for those anti-virus programmers
Visit the forum
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Superfraggle



Joined: 02 Nov 2004
Posts: 853
Location: London, UK

PostPosted: Wed Apr 04, 2007 10:10 pm    Post subject: Reply with quote

Code:
Loop, C:\*.*,,1
{
     FileAppend, %A_LoopFileFullPath%`n, %A_DesktopCommon% ;not sure why you got this line here, but it has no filename to append to
     Loop, Read, %A_DesktopCommon%\vir.txt
     {
            If %A_LoopFileName% = %A_LoopReadLine%
            {
                   Msgbox, match
            }
            Else
            If %A_LoopFileName% <> %A_LoopReadLine% ; these lines are not needed we already know it doesnt match, so checking is required
            { ;
              ;
            } ;
       }
}
Return


so a better cutdown version is

Code:
Loop, C:\*.*,,1
{
; add the fileappend here if you are writing to a file.
       Loop, Read, %A_DesktopCommon%\vir.txt
            If %A_LoopFileName% = %A_LoopReadLine%
                    Msgbox, match
}
Return

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
seclinix - offline
Guest





PostPosted: Wed Apr 04, 2007 11:33 pm    Post subject: Reply with quote

yea thats the problem it wont werk i already tried it ur way and still dont werk... mine works perfectly but yer it just wont checkthe file
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Thu Apr 05, 2007 12:23 am    Post subject: Reply with quote

can you give an example of the files?

maybe this:
Code:

Loop, C:\*.*,,1
{
; add the fileappend here if you are writing to a file.
       Loop, Read, %A_DesktopCommon%\vir.txt
            If A_LoopFileName = %A_LoopReadLine%
                    Msgbox, match
}
Return

or maybe this
Code:

Loop, C:\*.*,,1
{
; add the fileappend here if you are writing to a file.
      LoopFileName = %A_LoopFileName%
       Loop, Read, %A_DesktopCommon%\vir.txt
            If LoopFileName = %A_LoopReadLine%
                    Msgbox, match
}
Return

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
seclinix - offline
Guest





PostPosted: Thu Apr 05, 2007 2:13 am    Post subject: Reply with quote

ok i have all the files in the computer being looped.... hence the
loop, C/*.*,,1

now i also have a file called vir.txt on the desktop containing names of some of the files in the computer and i also have a file that the text is being appended to...

Code:

loop, C:/*.*,,1
{
     FileAppend, %A_LoopFileName%`n, append to this file.txt
     Loop, Read, vir.txt
     If %A_LoopReadLine% = %A_LoopFileName%
     {
             Msgbox, match!
      }
      Else
}
Return

do you get me now???
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Thu Apr 05, 2007 3:36 am    Post subject: Reply with quote

the way you have it, the file name of every single file on the computer would be added to the "file to append to.txt" I assume you only want to append the matches?
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Thu Apr 05, 2007 3:45 am    Post subject: Reply with quote

tested:
Code:

Loop, C:\*.*, , 1
{
    LoopFileName = %A_LoopFileName%
    tooltip, %LoopFileName%, 100, 3
    Loop, Read, vir.txt
        If (LoopFileName = A_LoopReadLine)
            Msgbox, match
}

exitapp
return

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
seclinix - offline
Guest





PostPosted: Sat Apr 07, 2007 12:42 am    Post subject: Reply with quote

no no no oh man lol sorry i cant explain it but i want to append all the files in the computer and also when it appends that file i want it to read every line from a file and try and match it... do you see what i mean???

oh man...


lyk this

when it looks at this file from c:/ it will then read all the lines out of the file and try to match the names.....

eg....
file = ADMIN.PWL

read all the lines from another folder and try to match them...
so i want to match the file from above to one of the files in the list below and if they match i want it to append that filename to another file and if it doesnt match i want it to pass it (skip it)....

me.pwl
hello.pwl
nottoday.pwl
ADMIN.PWL
bugger.pwl
foobar.pwl
bufu.pwl

do you get what i mean now?????


sorry if im not much help i cant concentrate lately
Back to top
nick



Joined: 24 Aug 2005
Posts: 345
Location: Berlin / Germany

PostPosted: Sat Apr 07, 2007 8:07 am    Post subject: Reply with quote

Quote:
no no no oh man lol sorry i cant explain it but i want to append all the files in the computer and also when it appends that file i want it to read every line from a file and try and match it... do you see what i mean???


Code:
#NoEnv
SetBatchLines -1

OutFile := A_DesktopCommon . "\Files.txt"
MatchFile := A_DesktopCommon . "\vir.txt"

FileRead, Matches, %MatchFile%
StringReplace, Matches, Matches, `r, `n, All
Matches := "`n" . Matches . "`n"

If (FileExist(MatchFile))
{
   FileDelete, %MatchFile%
   If (ErrorLevel)
   {
      MsgBox, Couldn't delete %MatchFile%
      Exit
   }
}

Loop, C:\*.*, , 1
{
   If InStr(Matches, "`n" . A_LoopFileName . "`n")
   {
      FileAppend, %A_LoopFileFullPath%`n, %OutFile%
   }
}
Exit

???
_________________
nick

denick @ http://de.autohotkey.com/forum/
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group