I'd like to use Keepass (win10x64).
The problem is that, I have my passwords gathered all these years like this:
each username/password pair in a separate text file,
having as filename the domain name of the relevant password,
and inside each .txt file, the first line is the username, and the 2nd the password (both without a prefix).
For example:
Filename: reddit.com
(it also has the .txt extension but that can be omitted)
Contents:
my_username
my_Password
In order the above to become an CSV it must be converted into:
"Account","Login Name","Password","Web Site", "Notes"
"Entry 1","my_username","my_password","http://reddit.com", ""
i.e.
"Account","Login Name", "Password", "Web Site", "Notes"
"Entry 1","my_username", "my_password", "http://reddit.com", ""
Note: if there is a comma (,
), double quote("
) or backslash(\
) in the password then it must be escaped with a backslash.
How can this be done via a bash script (cygwin)?
The code snippets I have gathered so far:
How can I prepend a string to the beginning of each line in a file? (source)
awk '{print "prefix" $0}' file
Print nth Line From file.txt (source)
awk "NR==2{print;exit}" file.txt // for printing the 2nd line
execute a command to all found files recursively
find . -name "*.txt" -execdir *command*
or alternatively
for file in /cygdrive/c/folder/*; do *command* // command example: mv "$file" "${file}/.." done
So, my script should start with:
find . -name "*.txt" -execdir awk '{print '"Account","Account","Login Name","Password","Web Site", "Notes"' $0}' "$file"
I'm stuck at this point.