Rename Image Files in Folders

This is a Python script to walk a directory tree, renaming .jpg and .JPG files. It was written for a client who had a directory containing multiple directories, each containing zero or more (up to 100) image files. Most of the images were named <abitrary name 1>.jpg or <arbitrary name 2>.JPG.
The client wanted each folder’s images to be numbered 001.jpg to nnn.jpg for some further process.

import os
import imghdr

def renamefiles(path):
rootstructure=os.path.abspath(path)
n = 0
for root, dirs, files in os.walk(rootstructure):
for f in files:
if os.getcwd() != root:
n = 0 # Reset the counter
os.chdir(root)

type = imghdr.what(f)
if type == 'jpeg':
n +=1
os.rename(f, str(n).zfill(3) + ".jpg")

# Specify the full path to the directory here.
renamefiles("/Users/myuser/Desktop/TheImageFolder")

Fern

A magical walkway through the woodlands of Perthshire.

via 500px https://ift.tt/2vZHT3o

Grav Error 403 in Admin Panel

I’m trying out Grav, a flat file CMS, on my server. It looks promising, having just installed it with the admin plugin. It seems that there is a fairly well-known problem with false positives from apache’s mod security web application firewall software, which manifests as an annoying 403 error banner in the admin pages (and the notifications panel not loading).

This is easily fixed by whitelisting mod security rule 350147. In Plesk, mod security rules can be whitelisted in the Server Management | Tools and Settings | Security | Web Application Firewall (ModSecurity) page. Enter the security rule ID (in this case 350147) in the box at the end of the page and click apply.

There is a security risk associated with this and users should assess the risk to their servers before implementing this workaround.

Locked parks say a lot about a city.

via Instagram https://ift.tt/2OeCuN5