{"id":1777,"date":"2022-09-20T09:00:00","date_gmt":"2022-09-20T09:00:00","guid":{"rendered":"https:\/\/blog.pafaarchives.org\/blog\/?p=1777"},"modified":"2022-09-07T13:43:22","modified_gmt":"2022-09-07T13:43:22","slug":"digital-treasure-trove-renaming-digital-files-using-python-scripts","status":"publish","type":"post","link":"https:\/\/blog.pafaarchives.org\/blog\/behind-the-scenes\/digital-treasure-trove-renaming-digital-files-using-python-scripts\/","title":{"rendered":"Digital Treasure Trove: Renaming Digital Files Using Python Scripts"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em> <em>Contributed by IMLS Grant Project Team<\/em> <\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In addition to rephotographing the permanent collection, the other goal of our current IMLS grant is the streamlining and unification of our file management and file naming systems for our digitized collections. Given PAFA\u2019s long history and the many hands that have made the Museum possible since its founding, there have been many different organizing schemes to keep the collection in order, and since the advent of digitized collection and databases, many more still to keep the file names organized.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In 2022, we have inherited many generations of images and information, and to best carry them forward in a safe and useful way\u2014and to prepare for the migration to a new database soon\u2014we need to reorganize and rename all the files in our digital collection.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To summarize the issue: every artwork is different, and over the years the file names of PAFA\u2019s digital collection have prioritized different information like artwork names, artist names, year of creation, names of donors, location the image was taken, conservation notes, and finally, the accession number, just to name a few. Our goal was to standardize these file names with what they all have in common and what is most unique to them\u2014their accession number.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This number, generally, is a compound of many different pieces of information such as the year PAFA acquired it, which acquisition group or gift did a work come to PAFA through in that year, and what number in each group is the artwork itself (among other pieces of information). From this number, we can easily link a specific artwork to any corresponding information we have about it in our database.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Take the number 2004.20.4, which is the accession number for the work <a href=\"https:\/\/www.pafa.org\/museum\/collection\/item\/conjunction\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Conjunction <\/em>by Romare Bearden<\/a>. We might find this filename in our database as \u201cBEARDEN-2004_20_4.tif,\u201d which, can certainly be used to correctly identify this work as it has done since it was acquired by PAFA in 2004, but even the addition of the last name of \u201cBEARDEN-\u201d as a prefix to the accession number makes for clunky cross-system use when not all the other file names match this same scheme.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"756\" src=\"https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image-2.jpeg\" alt=\"\" class=\"wp-image-1778\" srcset=\"https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image-2.jpeg 610w, https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image-2-242x300.jpeg 242w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The process for us to rename all these files, on paper, is simple enough. We just need to look for their accession number in the file name (usually buried under or inside of other unnecessary information) and replace all of this with just the simple accession number by itself. But this becomes immediately complicated as we find accession numbers that are formatted differently from one another or use version codes that are inconsistent with each other year to year.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To do this by hand, file by file, is, of course, technically possible but would be incredibly tedious and time-consuming. Thankfully, we have found a way to write and implement custom computer code (more commonly called a \u201cscript\u201d) to automate most of this process using the programming language Python.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"847\" height=\"951\" src=\"https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image.png\" alt=\"\" class=\"wp-image-1779\" srcset=\"https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image.png 847w, https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image-267x300.png 267w, https:\/\/blog.pafaarchives.org\/blog\/wp-content\/uploads\/2022\/09\/image-768x862.png 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Python is an incredibly flexible and powerful coding language, and through a variety of techniques, we have been able to instruct these custom scripts to automatically identify what is (and isn\u2019t) a PAFA accession number among other kinds of information inside of a file name, and then delete what isn\u2019t wanted or required. The script also helps us flag files that don\u2019t have a proper accession number at all, or have more complicated naming issues, which we can then set aside to look at by hand. The result, after applying the script to over 26,000 files, is a unified and easy to use set of file names, and a database overall that is ready for migration to a new and better system.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>This blog post is part of an ongoing series about Digital Collections that we are able to undertake thanks to a grant from the Institute of Museum and Library Services (IMLS).<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>About the Institute of Museum and Library Services<\/strong>&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Institute of Museum and Library Services is the primary source of federal support for the nation\u2019s libraries and museums. We advance, support, and empower America\u2019s museums, libraries, and related organizations through grantmaking, research, and policy development. Our vision is a nation where museums and libraries work together to transform the lives of individuals and communities. To learn more, visit <a href=\"https:\/\/www.imls.gov\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.imls.gov\/<\/a>and follow us on <a href=\"http:\/\/www.facebook.com\/USIMLS\" target=\"_blank\" rel=\"noreferrer noopener\">Facebook<\/a> and <a href=\"http:\/\/www.twitter.com\/us_imls\" target=\"_blank\" rel=\"noreferrer noopener\">Twitter<\/a>.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contributed by IMLS Grant Project Team In addition to rephotographing the permanent collection, the other goal of our current IMLS grant is the streamlining and unification of our file management and file naming systems for our digitized collections. Given PAFA\u2019s long history and the many hands that have made the Museum possible since its founding, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4,40,5,72],"tags":[10,14,39],"class_list":["post-1777","post","type-post","status-publish","format-standard","hentry","category-behind-the-scenes","category-collection","category-digital-archives","category-grant","category-metadata","tag-behind-the-scenes","tag-digital","tag-imls"],"_links":{"self":[{"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/posts\/1777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/comments?post=1777"}],"version-history":[{"count":3,"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/posts\/1777\/revisions"}],"predecessor-version":[{"id":1783,"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/posts\/1777\/revisions\/1783"}],"wp:attachment":[{"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/media?parent=1777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/categories?post=1777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pafaarchives.org\/blog\/wp-json\/wp\/v2\/tags?post=1777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}