Skip to content

Instantly share code, notes, and snippets.

@rettinghaus
rettinghaus / index_up.py
Created January 3, 2022 13:36
change 0-based file names to 1-based file names
import os
path = "YourPath"
_ext = ".png"
for (dirpath, dirnames, filenames) in os.walk(path):
if '0000' + _ext in filenames:
print(f"{dirpath} has zero-based index")
for filename in list(reversed(filenames)):
if filename[4:] == _ext:
os.rename(os.path.join(dirpath, filename), os.path.join(dirpath, str(int(filename[:4]) + 1).zfill(4) + _ext))
@rettinghaus
rettinghaus / authority-wikipedia.xsl
Created June 8, 2020 14:22
This is a little XSLT snippet, that, for a given authority control id, creates a link to a corresponding wikipedia entry in a specified language
<xsl:variable name="authority">
<!-- here goes the authority -->
</xsl:variable><xsl:variable name="identifier">
<!-- here goes the id -->
</xsl:variable><xsl:variable name="isoLang">
<!-- here goes the ISO 639-1 language code -->
</xsl:variable><xsl:variable name="property">
<xsl:choose>
<xsl:when test="$authority = 'viaf'">
<xsl:value-of select="214" />
@rettinghaus
rettinghaus / check-gnds.sh
Last active February 14, 2019 16:02 — forked from peterstadler/check-gnds.sh
Check Beacon File for outdated IDs
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Script for checking GND IDs.
# 1. Grab all GNDs from the beacon file
# 2. Check every GND by making a HEAD request and see whether the returned status code is 303
import httplib
from urlparse import urlparse