Skip to content

Instantly share code, notes, and snippets.

@Birchwell
Birchwell / exiftooladdmetadata.sh
Last active October 24, 2015 02:54
This Exiftool bash script will allow the user to populate 18 YAD fields with metadata for images. Useful for uploading images to Flickr.
#!/bin/bash
exiftoolform=$(yad --title "ExifTool" --form --width=700 --columns=2 --field="Artist:" --field="Copyright:" --field="City:" --field="State:" --field="Country:" --field="Creator:" --field="Rights:" --field="By-line:" --field="Headline:" --field="Description:" --field="Keywords 1:" --field="Keywords 2:" --field="Keywords 3:" --field="Keywords 4:" --field="Keywords 5:" --field="Keywords 6:" --field="Keywords 7:" --field="Keywords 8:" "John Doe" "(c) 2015 John Doe" "Chicago" "Illinois" "United States" "John Doe" "(c) 2015 John Doe" "John Doe")
OldIFS="$IFS"; IFS='|' # Save the old IFS value to OldIFS and give the new value to IFS.
read ARTIST COPYRIGHT CITY STATE COUNTRY CREATOR RIGHTS BYLINE HEADLINE DESCRIPTION KEYWORDSONE KEYWORDSTWO KEYWORDSTHREE KEYWORDSFOUR KEYWORDSFIVE KEYWORDSSIX KEYWORDSSEVEN KEYWORDSEIGHT <<< "$exiftoolform"
IFS="$OldIFS" # Give IFS back its original value.
exiftool -artist="$ARTIST" -copyright="$COPYRIGHT" -city="$CITY" -state="$STATE" -country="$COUNTRY" -creator="$CREA
@Birchwell
Birchwell / convert-image.sh
Created October 18, 2015 00:31
Convert images to many formats. Quality can be set. The converted images will be placed in a separate folder and the originals will be intact. Zenity must be installed.
#! /bin/sh
# Increment and count the number of files passed to the script
# for later use in the progress dialog box
n=1
# Ask for the destination graphic image format to change to
# Next line is entered all on one line
EXT=`zenity --title="Convert Image" --entry --text="Please
enter the image format to convert to (e.g. PNG, JPG, TIFF, WEBP etc.)"`
@Birchwell
Birchwell / convertvideo.sh
Created October 18, 2015 00:26
Convert video to avi, 3gp, flv, mov, mp4, asf, wmv, mkv, mpg. The video and audio bitrates can be customized.
!# /bin/bash
ConvertTo=$(zenity --list --column="Select One" --title="Video
Converter" --height=300 --width=250 --text="Select the format
to convert to" avi 3gp flv webm mov mp4 mkv asf wmv mpg mov)
@Birchwell
Birchwell / videotogif.sh
Created October 18, 2015 00:22
This bash script will work on multiple video files, outputting multiple GIFs renamed with incremental numbering.
#!/bin/bash
for f in ./*.mp4; do
ffmpeg -i "$f" -vf scale=420:-1 -t 10 -r 10 "${f%.*}.gif"
done
@Birchwell
Birchwell / file-size.sh
Created October 18, 2015 00:00
Shows the actual size of files in Thunar. Thunar has a strange problem of not reporting the correct size of files.
#! /bin/bash
kb=$((2**10))
mb=$((2**20))
for file in $@; do
if [ ! -e $file ]; then
continue
fi
b1=`ls -l $file | cut -d" " -f5`
@Birchwell
Birchwell / movefilesdir.sh
Created October 17, 2015 23:55
Divide files in folder into many folders. Customizable by changing number of files.
#!/bin/bash
c=1; d=1; mkdir -p dir_${d}
for file in *
do
if [ $c -eq 600 ]
then
d=$(( d + 1 )); c=0; mkdir -p dir_${d}
fi
@Birchwell
Birchwell / nix.sh
Created October 17, 2015 23:51
This Custom Action will produce contact sheets of videos. I found it here: http://p.outlyer.net/vcs/#issues
#!/usr/bin/env bash
#
# $Rev: 583 $ $Date: 2014-05-18 18:50:42 +0200 (dg, 18 mai 2014) $
#
# vcs
# Video Contact Sheet *NIX: Generates contact sheets (previews) of videos
#
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Toni Corvera
#
# This program is free software; you can redistribute it and/or
@Birchwell
Birchwell / nix.sh
Created October 17, 2015 13:07
This script will produce contact sheets of videos.
#!/usr/bin/env bash
#
# $Rev: 583 $ $Date: 2014-05-18 18:50:42 +0200 (dg, 18 mai 2014) $
#
# vcs
# Video Contact Sheet *NIX: Generates contact sheets (previews) of videos
#
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Toni Corvera
#
# This program is free software; you can redistribute it and/or
@Birchwell
Birchwell / chopvideoaudio.sh
Created October 17, 2015 06:09
This bash script skirts the annoying FFmpeg limitation of cutting audio or video based not on start/stop timestamps, but on seconds elapsed. With the following bash script you can enter a start time to begin the cut, and an end time to terminate the cut, which removes the sometimes necessary task of performing math to determine precisely how man…
#!/bin/bash
INPUT=$(yad --width=600 --height=400 --file-selection --file-filter='*.mp3 *.mkv *.mp4 *.avi *.flv')
eval $(yad --width=400 --form --field=start --field=end --field=output:SFL "00:00:00.000" "00:00:00.000" "${INPUT/%.*}-out.${INPUT##*.}" | awk -F'|' '{printf "START=%s\nEND=%s\nOUTPUT=\"%s\"\n", $1, $2, $3}')
[[ -z $START || -z $END || -z $OUTPUT ]] && exit 1
DIFF=$(($(date +%s --date="$END")-$(date +%s --date="$START")))
OFFSET=""$(($DIFF / 3600)):$(($DIFF / 60 % 60)):$(($DIFF % 60))
@Birchwell
Birchwell / dimensionsortzenity.sh
Created October 17, 2015 03:38
Sort images by dimension, and check the images to delete.
#!/bin/bash
#expecting 2 args:
# function display or delete
# a directory containing images
ZENITY_X=0
ZENITY_Y=0
ZENITY_W=500
ZENITY_H=400