Skip to content

Instantly share code, notes, and snippets.

View Phlow's full-sized avatar
🐙
🎛️ 🔊

Moritz »mo.« Sauer Phlow

🐙
🎛️ 🔊
View GitHub Profile
@Phlow
Phlow / rename-files-with-date.sh
Created October 11, 2015 10:20
Rename files and use their date
#!/bin/bash
# Copy MP3 files in a directory to a new name based solely on creation date
# FROM: foo.mp3 Created on: 2012-04-18 18:51:44
# TO: 20120418_185144.mp3
for i in *.mp3
do
# mod_date=$(stat -c "%y" "$i"|sed 's/\..*$//')
# mod_date=$(stat -c "%y" "$i"|awk '{print $1"_"$2}'|sed 's/\..*$//')
mod_date=$(stat --format %y "$i"|awk '{print $1"_"$2}'|cut -f1 -d'.'|sed 's/[: -]//g')
cp "$i" "$mod_date".mp3
@Phlow
Phlow / screenshot-optimizer.sh
Last active October 11, 2015 18:06
Shell-Script renaming screenshots, making thumbnails and optimizing images with ImageOptim
#
# Rename Screenshots, Make Thumbnails, Optimize Images with Imageoptim
#
clear;
echo -e '\n- - - - - - - - - - - - - - - - -';
echo -e '\n Screenshotter V.1.0 ';
echo -e '\n- - - - - - - - - - - - - - - - -';
# Wenn Variablen gesetzt sind, dann bitte los...
@Phlow
Phlow / rename-files-and-add-suffix.sh
Created September 23, 2015 19:31
Rename files and add a suffix
for file in *; do mv $file `basename $file `.md; done
@Phlow
Phlow / wordpress-downloader.sh
Last active May 25, 2020 21:00
Batch Script – Download, Extract, Prepare WordPress and Plugins
# This script fetches WordPress plus some plugins with Wget,
# extracts everything, removes clutter and moves plugins into
# the right places.
#
# Option -e prints escape sequences like breaks \n
#
reset='\x1B[0m'
green='\x1b[0;32m'
yellow='\x1b[0;33m'
@Phlow
Phlow / rename-files-and-replace.sh
Last active September 30, 2015 12:08
Rename files and replace text with new text
# Rename file and replace OLDTEXT with NEWTEXT
# for filename in *.jpg; do mv "$filename" "${filename//OLDTEXT/NEWTEXT}"; done
# replace large with nothing
for filename in *.jpg; do mv "$filename" "${filename//large/}"; done
for filename in *.xml; do mv "$filename" "${filename//_meta.xml/.md}"; done
@Phlow
Phlow / rename-files.sh
Created August 15, 2015 09:10
A collection of methods to rename files in terminal
#
# Rename multiple files and replace name with number and prefix
# %02 › digits of numbers (increase when lots of files)
#
# counter=1
# for i in *.*
# do new=$(printf "%02d.jpg" "$counter")
# mv -- "$i" "screenshot-realaudio-$new"
# let counter=counter+1
# done
@Phlow
Phlow / batch_download.sh
Last active August 29, 2015 14:27
Batch Download via Terminal with explanation
#
# 1. Download file › batch_download.sh
# 2. Edit file › URLs for wget to download
# 3. With -O you can rename the output file
# 4. Change permissions of file $ chmod 755 batch_download.sh
# 5. Start the batch $ ./batch_download.sh
#
wget https://archive.org/compress/kpu008 -O kpu008.zip
wget https://archive.org/compress/kpu009 -O kpu009.zip
@Phlow
Phlow / MySQL Queries When Moving WordPress.sql
Last active May 6, 2020 17:29
MySQL Queries When Moving WordPress
/*
There's a better tool https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
MySQL Queries When Moving WordPress
To use this snippet, you have to:
1. Change the table prefix according your installation. In the example it's: wp_
2. Change http://old-domain.com to your old domain.
@Phlow
Phlow / Loop through all pages of all collections
Created July 28, 2015 17:36
Loop through all pages of all collections
{% comment %}
#
# Loop through all pages of all collections
#
{% endcomment %}
{% for c in site.collections %}
{% assign docs=c[1].docs %}
{% for doc in docs %}
// do something
{% endfor %}
@Phlow
Phlow / for-loop-sorted-collection
Last active April 30, 2024 13:30
This Liquid loop for Jekyll sorts a collection by date in reverse order
{% comment %}
*
* This loop loops through a collection called `collection_name`
* and sorts it by the front matter variable `date` and than filters
* the collection with `reverse` in reverse order
*
* To make it work you first have to assign the data to a new string
* called `sorted`.
*
{% endcomment %}