JSBGAMES Posted February 22, 2021 Posted February 22, 2021 Hello guys i need a little help with this scipt, i already managed to delete the blank lines from a text file but i also need to delete a part of the remaining lines. example: "black tide: show me the way | 90003", I want to stay like this "| 90003" #include <Array.au3> Sleep (2000) Local $rFile = (@ScriptDir & "\playlist.txt") Local $aFile = FileReadToArray($rFile) Local $wFile = FileOpen(@ScriptDir & "\playlist.txt",2) For $i = 0 To UBound($aFile) -1 Step +1 If $aFile[$i] <> "" Then Sleep(100) FileWriteLine($wFile,StringStripWS($aFile[$i],3)) EndIf Next Lmp.au3Fetching info... playlist.txtFetching info...
Moderators JLogan3o13 Posted February 22, 2021 Moderators Posted February 22, 2021 (edited) Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Expand Moderation Team Edited February 22, 2021 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
mikell Posted February 22, 2021 Posted February 22, 2021 ? $sFile = FileRead(@ScriptDir & "\playlist.txt") $txt = StringRegExpReplace($sFile, '(?m)^(?|\h*\R|[^\|]+)|\h+$', "") FileWrite(@ScriptDir & "\playlist2.txt", $txt)
junkew Posted February 22, 2021 Posted February 22, 2021 Something like this if your file is to big to read then use filewriteline to write to a new file stringmid and stringinstr can help to find first | $hFile = FileOpen(@ScriptDir & "\playlist.txt", 0) If $hFile = -1 Then MsgBox(0, "Error", "FileOpen failed check your file for existence") Exit EndIf ;~ Read in lines of text until EOF While 1 $txtLine = FileReadLine($hFile) If @error = -1 Then ExitLoop If @error Then MsgBox(0, "Error", "FileReadLine returned @error to: " & @error) if ($txtLine <> "") then consolewrite(stringmid($txtLine,stringinstr($line,"|"))) else ;~ its a blank line so do nothing endif Wend ConsoleWrite("EOF") FileClose($hFile) FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
JSBGAMES Posted February 22, 2021 Author Posted February 22, 2021 Thanks @mikell and @junkew @mikell your example worked perfect for me, I just need it to be written in the same playlist.txt file or replacing the previous one
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now