Quote:
Originally Posted by JimmXinu
Glad to help.
bookid doesn't change.
"db.search_getting_ids('title:"~[a-z]" or author:"~[a-z]"', None)" searches the library, giving you back ids (rather than row numbers in the current view) for the search 'title:"~[a-z]" or author:"~[a-z]"' without a restriction(the None).
'title:"~[a-z]" or author:"~[a-z]"' is a search of two regular expressions saying 'any book with title containing letters a-z (not A-Z)' or 'any book with author(s) containing letters a-z (not A-Z)'
Rather than loop twice, you might just change the name twice in the same loop.
|
Code with only a loop.
Code:
db = self.gui.current_db
bookids = db.search_getting_ids('title:"~[a-z]" or author:"~[a-z]"', None)
for bookid in bookids:
mi = db.get_metadata(bookid,index_is_id=True)
mi.title = mi.title.upper()+'_T#@§'
auths=[]
for auth in mi.authors:
auths.append(auth.upper()+'_T#@§')
mi.authors = auths
db.set_metadata(bookid,mi)
mi = db.get_metadata(bookid,index_is_id=True)
mi.title = mi.title[:-5]
auths=[]
for auth in mi.authors:
auths.append(auth[:-5])
mi.authors = auths
db.set_metadata(bookid,mi)
db.refresh_ids(bookids)
Changed are saved on disk when db.set_metadata(bookid,mi) is executed?
Which module should I import?
Xwang