cd /path/to/dir
shopt -s nullglob
for file in *.{avi,rmvb,mkv}
do
directory="${file%.*}" # remove file extension
directory="${directory//_/ }" # replace underscores with spaces
darr=( $directory )
darr="${darr[@]^}" # capitalize the directory name
echo mkdir -p -- "$darr" # create the directory;
echo mv -b -- "$file" "$darr" # move the file to the directory
echo
done
Bash
Duplicity bash script to restore data from S3
Restore your S3 duplicity backup
#!/bin/bash
if [ $# -lt 3 ] || [ $# -gt 3 ]; then
echo 'invalid number of parameters passed'
echo 'Usage: s3-restore <bucket-name> <folder-name> <output-folder>'
else
echo 'restoring backup'
export PASSPHRASE=your_passphrase
export AWS_ACCESS_KEY_ID=your_aws_access_key
export AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
duplicity s3://s3.amazonaws.com/$1/$2 $3
fi
Backup to S3 using duplicity
Backup a directory to S3. The script make full backups every 30 days and incremental backups the rest of the time.
#!/bin/bash
if [ $# -lt 3] || [ $# -gt 3]; then
echo 'invalid number of parameters'
echo 'Usage: backup <folder-to-backup> <bucket-name> <folder-name>'
else
echo 'starting backup'
export PASSPHRASE=your_passphrase
export AWS_ACCESS_KEY_ID=your_aws_access_key
export AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
duplicity --extra-clean --full-if-older-than 1M $1 s3://s3.amazonaws.com/$1/$2
fi
My bashrc file
# Bash colouring PS1="\[\033[0;33m\]\u\[\033[0m\]\[\033[0;32m\]@\h\[\033[0m\] \[\033[0;35m\]\w\[\033[0m\]\[\033[0;31m\]>\[\033[0m\] " # Start tmux if it's screen : ) if [[ ! $TERM =~ screen ]]; then exec tmux fi # Aliases alias v="vim" alias art="php artisan" alias gita="git add -A" alias gits="git status" alias gitc="git commit -m "
My bash_profile file
# include the .bashrc file if [ -f ~/.bashrc ]; then . ~/.bashrc # read ~/.bashrc, if present. fi