I am working with Windows PowerShell and have very limited programming experience 🙁
Ihave a text file (LaTeX bib file) that is filled with ~30.000 items of the following form:
@incollection{Abdulla.2022,
author = {Abdulla, Sara M.},
title = {{Underground anti-woman and incel movements and their connections to sexual assault}},
pages = {3601--3626},
publisher = {{Springer International}},
editor = {Geffner, Robert and White, Jacquelyn W. and Hamberger, L. Kevin and Rosenbaum, Alan and Vaughan-Eden, Viola and Vieth, Victor I.},
booktitle = {{Handbook of Interpersonal Violence and Abuse Across the Lifespan}},
year = {2022},
address = {Berlin and Oxford and New York},
doi = {10.1007/978-3-319-89999-2_198},
file = {Abdulla 2022 - Underground anti-woman and incel movements:Attachments/Abdulla 2022 - Underground anti-woman and incel movements.pdf:application/pdf}
}
In the line starting with address = {
, I need to replace " and "
by ", "
, so that the line will read address = {Berlin, Oxford, New York}
. However, I do not wish to replace " and "
in the title or editor lines.
I know I’d simply use something like (Get-Content lit.bib -Raw).Replace(' and ', ', ') | Out-File -encoding UTF8 lit.bib
to replace it in all lines, but how can I manage to do it only in lines starting with address = {
? (Most likely an if-statement, but I don’t know how to do it exactly.
Thanks a lot!