pbecks1963 Posted March 10, 2010 Posted March 10, 2010 Hello y'all, I use this script to remove @crlf from all lines in a text-file $czFile = "\test.csv" ;search & replace $szText = FileRead($szFile,FileGetSize($szFile)) $szText = StringReplace($szText, @CRLF, "") FileDelete($szFile) FileWrite($szFile,$szText) I need to do this with multiple csv-files (which are all located in one folder) Can someone help me with building the loop that will read te filenames one by one and putting them in this script (as a variable). ?
99ojo Posted March 10, 2010 Posted March 10, 2010 (edited) Hi, #include <file.au3> ; !! there are no error handlings in this code !! $source = "c:\csv" ;list csv files in $source into array, for more details see helpfile $arfiles = _FileListToArray ($source, "*.csv", 1) ;loop over array, $arfiles [0] = Number of Files\Folders returned, so we start from 1 For $i = 1 To UBound ($arfiles) - 1 ;search & replace $szFile = $source & "\" & $arfiles [$i] $szText = FileRead($szFile,FileGetSize($szFile)) $szText = StringReplace($szText, @CRLF, "") FileDelete($szFile) FileWrite($szFile,$szText) Next ;-)) Stefan Edited March 10, 2010 by 99ojo
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