add suffix to the end of every line of every text file

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
way2000
Posts: 58
Joined: 15 Jul 2016, 08:57

add suffix to the end of every line of every text file

16 Sep 2018, 09:36

i need a script that can add a suffix to every line of every text file in a folder

does anyone have an example i can work with?

please help if possible
garry
Posts: 3777
Joined: 22 Dec 2013, 12:50

Re: add suffix to the end of every line of every text file

16 Sep 2018, 10:12

example
( instead delete original file can also write to a new file )

Code: Select all

;- reads textfiles and add  "_ADD" at end of line
setworkingdir,%a_scriptdir%
Extensions:= "txt,bas,bat"      ;- some extensions
PRESELECT  =%a_desktop%         ;- search from here

FileSelectFolder,MF,%PRESELECT%
if MF=
  return
setworkingdir,%MF%
Loop, %mf%\*.*, 0, 1
  {
  If A_LoopFileExt in %Extensions%
   {
   e=
   y:=A_LoopFileFullPath
    FileRead,aa,%y%
	  Loop, parse,aa, `n, `r
      {
	  x := a_loopfield
      if (x="")
	    continue
	  e .= x . "_ADD`r`n"
      }
   ;Filedelete,%y%	     ;- instead delete can also write to a new file
   ;Fileappend,%e%,%y%
   new=%dir%\%name_no_ext%_NEW.%ext%
   ;msgbox,%new%
   Fileappend,%e%,%new%
   e=   
   }
 }
run,%mf% 
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 144 guests