Sign in to follow this  
Followers 0
B3TA_SCR1PT3R

file delete line?

13 posts in this topic

yeah so i got a really big .txt file and i only wont the word "Directory" deleted from it how would i go about doing this..it has about 200-300 lines and the words appears about every 20-30 lines.? ..so?


[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites



probably the best way is to filereadtoarray then stringreplace for each line in the array then write the file back out.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
#include <file.au3>
#include <Process.au3>
GLOBAL $aRecords
GuiCreate("*Insert Flashy Title Here*",700,400)
$tree = GuiCtrlCreateTreeView(25,50,500,200)
$BTN_1 = GuiCtrlCreateButton("List Files",100,300,75,35)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        Select
        Case $msg = $BTN_1 
            _RunDOS("dir /s >> C:\~~Files.txt")
            _FileReadToArray("C:\~~Files.txt",$aRecords)
                If @error = 1 Then MsgBox(4096 + 16,"Error"," Error reading file to Array")
            For $x = 1 to $aRecords[0]
                GuiCtrlCreateTreeViewItem($aRecords[$x],$tree)
            Next
        EndSelect
WEnd

should i even attempt to clean out all the crap in that file? look how many stringreplace or watever id have to do?


[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Wanting to delete the line or just the word?

Example of removing the line:

#include <GuiConstants.au3>
#include <file.au3>
#include <Process.au3>
#include <Array.au3>

GLOBAL $aRecords
GuiCreate("*Insert Flashy Title Here*",700,400)
$tree = GuiCtrlCreateTreeView(25,50,500,200)
$BTN_1 = GuiCtrlCreateButton("List Files",100,300,75,35)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        Select
        Case $msg = $BTN_1 
            _RunDOS("dir /s > C:\~~Files.txt")
            _FileReadToArray("C:\~~Files.txt",$aRecords)
                If @error = 1 Then MsgBox(4096 + 16,"Error"," Error reading file to Array")
                _CleanUp($aRecords, "Directory of")
            For $x = 1 to $aRecords[0]
                GuiCtrlCreateTreeViewItem($aRecords[$x],$tree)
            Next
        EndSelect
WEnd

Func _CleanUp(ByRef $aRecords, $s_remove)
    For $x = 1 To $aRecords[0]
        If StringInStr($aRecords[$x],$s_remove) Then
            _ArrayDelete($aRecords, $x)
            $aRecords[0] = $aRecords[0] - 1
        EndIf
    Next
EndFunc
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Wanting to delete the line or just the word?

Example of removing the line:

#include <GuiConstants.au3>
#include <file.au3>
#include <Process.au3>
#include <Array.au3>

GLOBAL $aRecords
GuiCreate("*Insert Flashy Title Here*",700,400)
$tree = GuiCtrlCreateTreeView(25,50,500,200)
$BTN_1 = GuiCtrlCreateButton("List Files",100,300,75,35)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        Select
        Case $msg = $BTN_1 
            _RunDOS("dir /s > C:\~~Files.txt")
            _FileReadToArray("C:\~~Files.txt",$aRecords)
                If @error = 1 Then MsgBox(4096 + 16,"Error"," Error reading file to Array")
                _CleanUp($aRecords, "Directory of")
            For $x = 1 to $aRecords[0]
                GuiCtrlCreateTreeViewItem($aRecords[$x],$tree)
            Next
        EndSelect
WEnd

Func _CleanUp(ByRef $aRecords, $s_remove)
    For $x = 1 To $aRecords
        If StringInStr($aRecords[$x],$s_remove) Then
            _ArrayDelete($aRecords, $x)
            $aRecords[0] = $aRecords[0] - 1
        EndIf
    Next
EndFunc

<{POST_SNAPBACK}>

hey thanks alot man this is exactly wat i needed .....but it only removes the first "Directory of"

im thinkin a Do...Until (array = 0) but i dont know how to word that..or anything else would be fine to


[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

Noticed that also, fixed it:

#include <GuiConstants.au3>
#include <file.au3>
#include <Process.au3>
#include <Array.au3>

GLOBAL $aRecords
GuiCreate("*Insert Flashy Title Here*",700,400)
$tree = GuiCtrlCreateTreeView(25,50,500,200)
$BTN_1 = GuiCtrlCreateButton("List Files",100,300,75,35)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        Select
        Case $msg = $BTN_1 
            _RunDOS("dir /s > C:\~~Files.txt")
            _FileReadToArray("C:\~~Files.txt",$aRecords)
                If @error = 1 Then MsgBox(4096 + 16,"Error"," Error reading file to Array")
                _CleanUp($aRecords, "Directory of")
            For $x = 1 to $aRecords[0]
                GuiCtrlCreateTreeViewItem($aRecords[$x],$tree)
            Next
        EndSelect
WEnd

Func _CleanUp(ByRef $aRecords, $s_remove)
    $x = 1
    do
            $aRecords[$x] = StringStripCR($aRecords[$x])
            If Stringlen($aRecords[$x]) = 0 Then
                _ArrayDelete($aRecords, $x)
                $aRecords[0] = $aRecords[0] - 1
            ElseIf StringInStr($aRecords[$x],$s_remove) Then
                _ArrayDelete($aRecords, $x)
                $aRecords[0] = $aRecords[0] - 1
            Else
                $x = $x + 1
            EndIf
    Until $x = $aRecords[0]
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

hey how many files do you have in your tree list thing

mynes 6000+


[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ouch, 2000+ but i have a fileserver so this one doesn't get cluttered.

<{POST_SNAPBACK}>

ah so..

..now comes the hardest task.........making treeitems for each directory :D:D:dance::D:dance::whistle: <<thats how i feel combined for >> :(

hey theres something to brag about to the ladies...(6000+ files)

Edited by B3TA_SCR1PT3R

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

2,000? 6,000? :whistle:

I reformatted this computer a mere week ago and my system drive contains 20,516 files without any personal files stored on it.

Share this post


Link to post
Share on other sites

2,000? 6,000? :whistle:

I reformatted this computer a mere week ago and my system drive contains 20,516 files without any personal files stored on it.

<{POST_SNAPBACK}>

...wat are you running ALL windows versions?

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

Nope, just one fresh install of XP Pro SP2. The Windows folder itself has 11,500 files in it though.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0