Skip to content
⌘ NSIS Forum Archive

How U Copy "all" the text in a file

4 posts

WiLdWoLfStray#edited

How U Copy "all" the text in a file

I need to copy all the lines of text in many files with other names
[Note] the #of lines is known.

Please help.
This is what i have so far.
Function resfiles
;============================================
ReadINIStr $R8 "$PLUGINSDIR\main.ini" "Field 12" "State"
ReadINIStr $R8 "$PLUGINSDIR\main.ini" "Field 4" "State"
ReadINIStr $R7 "$PLUGINSDIR\main.ini" "Field 14" "State"
FileOpen $R5 "ResFileInput.txt" r
FileRead $R5 $R6
FileClose $R5
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Push "$R8\$R7.txt" # output file
Push "*.bsp" # filter
Push "$R8" # folder to search in
;---------------------------------------------
Exch $R0 #path
Exch
Exch $R1 #filter
Exch
Exch 2
Exch $R2 #output file
Exch 2
Push $R3
Push $R4
Push $R5
ClearErrors
FindFirst $R3 $R4 "$R0\$R1"
Loop4:
IfErrors Done4
StrCpy $R4 $R4 -4
DetailPrint "Found Map: $R4"
DetailPrint "Created $R4.res"
StrCpy $R4 "$R8\$R4.res"
FileOpen $R5 $R4 w
FileWrite $R5 '"resources"$\r$\n{$\r$\n$R6$\r$\n}'
FileClose $R5
FindNext $R3 $R4
Goto Loop4

Done4:
FileClose $R5
FindClose $R3
nores1:
FunctionEnd
kichik#
According to your script, it looks like you're trying to copy everything in one file into many other files. If that's what you're trying to do, there's no need to use FileOpen, FileRead, FileWrite and FileClose. Simply use CopyFiles to copy the entire file.