help me with text creator
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
help me with text creator
hi, i'm wanting to make a script for example, it takes a list of words from a notepad for example,
house
car
bus
and it adds numbers to the end of each one without repeating for example
house1
car1
bus1
from 1, 0001 to 9999
and saves it again in a new file, would that be possible?
thank you
house
car
bus
and it adds numbers to the end of each one without repeating for example
house1
car1
bus1
from 1, 0001 to 9999
and saves it again in a new file, would that be possible?
thank you
Re: help me with text creator
Code: Select all
count := {}, out := "", new := A_ScriptDir "\new.txt"
ControlGetText, text, Edit1, ahk_exe notepad.exe
For each, line in StrSplit(text, "`r`n")
count[line] := (0 count[line]) + 1, out .= "`n" line count[line]
FileRecycle, %new%
FileAppend, % SubStr(out, 2), %new%
Run, "%new%"
Last edited by mikeyww on 27 Sep 2021, 15:20, edited 1 time in total.
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
Re: help me with text creator
the notepad I wanted to say , is to get the notepad keywords from some way , for example C:\Users\admin\Desktop\here.txt
the script works fine, would it be possible to put it in this form?
house1
house2
house3 <- until 9999
car1
car2
car3 <- until 9999
bus1
bus2
bus3 <- until 9999
the script works fine, would it be possible to put it in this form?
house1
house2
house3 <- until 9999
car1
car2
car3 <- until 9999
bus1
bus2
bus3 <- until 9999
Re: help me with text creator
Code: Select all
word := [], count := {}, out := "", new := A_ScriptDir "\new.txt", max := 9999
ControlGetText, text, Edit1, ahk_exe notepad.exe
For each, item in StrSplit(Trim(text, "`r`n"), "`r`n")
word.Push(count.HasKey(item) ? "" : item), count[item] := (0 count[item]) + 1
For each, item in word
Loop, % Min(count[item], max)
out .= "`n" item A_Index
FileRecycle, %new%
FileAppend, % SubStr(out, 2), %new%
Run, "%new%"
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
Re: help me with text creator
is there a way to choose which file it will take as keywords? I run the file you wrote me and it creates words, but I don't know where it's getting them,
but for the help I'll thank you, you're a beast!
but for the help I'll thank you, you're a beast!
Re: help me with text creator
Code: Select all
; file = %A_ScriptDir%\words.txt ; Change file path as needed
FileSelectFile, file,,, Select a file, Text documents (*.txt)
If (file = "")
Return
word := [], count := {}, out := "", new := A_ScriptDir "\new.txt", max := 9999
If !FileExist(file) {
MsgBox, 48, Error, File not found.`n`n%file%
Return
} Else FileRead, text, %file%
For each, item in StrSplit(Trim(text, "`r`n"), "`r`n")
word.Push(count.HasKey(item) ? "" : item), count[item] := (0 count[item]) + 1
For each, item in word
Loop, % Min(count[item], max)
out .= "`n" item A_Index
FileRecycle, %new%
FileAppend, % SubStr(out, 2), %new%
Run, "%new%"
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
Re: help me with text creator
well, now I understand the program but it is not numbered as keywords, for examplemikeyww wrote: ↑27 Sep 2021, 15:58Code: Select all
; file = %A_ScriptDir%\words.txt ; Change file path as needed FileSelectFile, file,,, Select a file, Text documents (*.txt) If (file = "") Return word := [], count := {}, out := "", new := A_ScriptDir "\new.txt", max := 9999 If !FileExist(file) { MsgBox, 48, Error, File not found.`n`n%file% Return } Else FileRead, text, %file% For each, item in StrSplit(Trim(text, "`r`n"), "`r`n") word.Push(count.HasKey(item) ? "" : item), count[item] := (0 count[item]) + 1 For each, item in word Loop, % Min(count[item], max) out .= "`n" item A_Index FileRecycle, %new% FileAppend, % SubStr(out, 2), %new% Run, "%new%"
house1
house12
house123
house1234
Re: help me with text creator
It looks like you should step back and provide the exact example that you want, in detail, including both the complete input text and the complete output text. Figure out exactly what you need before you post. The posted script provides output that matches that in your earlier post.
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
Re: help me with text creator
what I need is to load a notepad with some keywords and for each keyword number from 1 to 9999 at the end of the keywordmikeyww wrote: ↑27 Sep 2021, 16:17It looks like you should step back and provide the exact example that you want, in detail, including both the complete input text and the complete output text. Figure out exactly what you need before you post. The posted script provides output that matches that in your earlier post.
example
house1
house2
house3
house9999
bike1
bike2
bike3
bike9999
Re: help me with text creator
That's a real example of the exact output? What was the input? What rules have determined your suffix numbers in your example? In other words, how is the suffix number determined?
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
Re: help me with text creator
I simply want any keyword that is in the notepad that I load to be added to the numbers from 1 to 9999 in all the available keywords in the notepad leaving the keyword from 1 to 9999 with no repeats.
Re: help me with text creator
I will just ask for an example a third time: what is an exact input file, and the exact output that you would want for it?
-
- Posts: 9
- Joined: 22 Apr 2021, 16:27
Re: help me with text creator
I managed to understand the code and it's serving me now, thanks for the help