dcamt
Publicado por Jean Michel 26/11/2004
[ Hits: 4.797 ]
Script para renomear, dimencionar, e organizar imagens
apartir de diretórios ou cameras digitais.
#!/bin/bash
#################################################################################
# #
# DCAMTOOLv2.0: Rename and resize your pictures. #
# requeriments: grep, awk, imagemagick #
# #
#################################################################################
# Copyright (C) 2004 Jean Michel Feltrin feltrin@gmail.com #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software Foundation, #
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
# #
# #
#################################################################################
echo -e " _ _"
echo -e " __| | ___ __ _ _ __ ___ | |_"
echo -e " / _ |/ __/ _ | '_ _ \| __|"
echo -e "| (_| | (_| (_| | | | | | | |_"
echo -e " \__,_|\___\__,_|_| |_| |_|\__|"
echo -e
# Configures:
WDIR="$PWD" # WORK DIRECTORY
TITLE="dsc" # EVENT NAME
INUM=0 # INCREMENT NUMBER
RSIZE="640x480" # RESIZE VALUE
ALBUM="/home/$USER/Album" # Album colection Dir
TITLE=$(echo "$TITLE`date +%d%m%y`")
CDEV="/dev/sda1" # Your Digital Camera Device
######################################################
# Album Configure
ALBUM="/home/$USER/Album" # Album colection Dir
if [ ! -d $ALBUM ]; then
mkdir $ALBUM
fi
YDATE=`date +%Y`
ptMES="Janeiro Fevereiro Março Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro"
cmes=0
for enPT in `echo $ptMES`; do
let cmes=$cmes+1
if [ $cmes = `date +%m` ]; then
MDATE=$enPT
fi
done
if [ ! -d $ALBUM/$YDATE/$MDATE ]; then
mkdir -p $ALBUM/$YDATE/$MDATE
fi
ABDIR=$ALBUM/$YDATE/$MDATE
######################################################
# Warning! if you set this options it'll copy all your
# pictures from your memory stick to your machine
# CDIR THE DIR WITH THE CAM PICTURES
# you should check this directory according to your cam
CDIR="/mnt/cam/dcim/101msdcf"
######################################################
if [ "`mount | grep $CDEV | awk '{print $1}'`" = "/dev/sda1" ]; then
echo "Would you work on you digital camera pictures,"
echo -n "it will copy all your camera file to: /tmp/dcamt/, would you ? (y/n):"
read mfop
MFFREE=`echo $mfop | tr [A-Z] [a-z]`
if [ $MSFREE != "N" ]; then
if [ ! -d /tmp/dcamt ]; then
mkdir /tmp/dcamt
fi
cp $CDIR/* /tmp/dcamt/
WDIR="/tmp/dcamt"
fi
fi
######################################################
if [ ! -z $1 ]; then
TITLE="$1"
TITLE=$(echo "$TITLE`date +%d%m%y`")
fi
if [ ! -z $2 ]; then
RSIZE="$2"
echo $RSIZE
if [ $RSIZE = "1024x768" ]; then
RSIZE="1024x768"
elif [ $RSIZE = "800x600" ]; then
RSIZE="800x600"
elif [ $RSIZE = "640x480" ]; then
RSIZE="640x480"
else
RSIZE="640x480"
fi
fi
if [ ! -z $3 ]; then
#RENAME
rlop="$3"
fi
if [ ! -z $4 ]; then
#SIZE
lop="$4"
fi
if [ ! -z $5 ]; then
#MOVE
mlop="$5"
fi
function showcf()
{
echo
echo "Configure:"
echo -e "\t WORKDIR\t:[ $WDIR ]"
echo -e "\t TITLE\t\t:[ $TITLE ]"
echo -e "\t RESIZED VALUE\t:[ $RSIZE ]"
echo "--------------------------------"
echo
}
showcf
function conf()
{
lcop=$6
echo -n "Would you change the configuration ? (y/n): "
if [ -z $lcop ]; then
read cop
lcop=`echo $cop | tr [A-Z] [a-z]`
fi
if [ "$lcop" = "y" ]; then
echo "! To keep the default just press ENTER !"
echo
echo -n "Workdir: "
OWDIR=$WDIR
read WDIR
if [ -z $WDIR ]; then
WDIR=$OWDIR
fi
echo -n "Title: "
OTITLE=$TITLE
read TITLE
if [ -z $TITLE ]; then
TITLE=$OTITLE
fi
echo -n "Resize: "
OLDRSIZE=$RSIZE
read RSIZE
if [ -z $RSIZE ];then
RSIZE=$OLDRSIZE
fi
echo
showcf
fi
}
conf
# RENAME THE FILE
if [ -z $rlop ]; then
rlop=n
fi
while [ $rlop != "y" ];
do
echo -n "Would you rename the files ? (y/n): "
read op
rlop=`echo $op | tr [A-Z] [a-z]`
if [ $rlop = "y" ]; then
for FILE in `ls $WDIR/*.jpg`
do
if [ $FILE = "dcamt.sh" ] || [ $FILE = "dcamt" ]; then
continue
fi
let INUM=$INUM+1
EVNUM=`echo "$TITLE-0"`
RENAME=`echo "$EVNUM$INUM.jpg"`
if [ "$FILE" != "$RENAME" ]; then
echo "Renaming: $FILE to $RENAME"
mv $FILE $WDIR/$RENAME
else
echo "RENAME: The files were with the same name."
break
fi
done
#
fi
if [ $rlop = "n" ]; then
break
fi
done
# Image Size
if [ "$OSIZE" = "$RSIZE" ]; then
echo "RESIZE: The files are with the same size."
else
if [ -z $lop ]; then
lop=n
fi
while [ $lop != "y" ];
do
echo -n "Would you chage your images size $OSIZE to $RSIZE ? (y/n): "
read op
lop=`echo $op | tr [A-Z] [a-z]`
if [ $lop = "n" ]; then
break
fi
done
if [ $lop = "y" ]; then
for FILE in `ls $WDIR/*.jpg`
do
OSIZE=`convert -verbose $FILE /dev/null | head -n 1 | cut -d " " -f3 | cut -d "+" -f 1`
echo "Converting $FILE with $OSIZE to $RSIZE"
convert -size $OSIZE $FILE -resize $RSIZE $FILE
done
fi
fi
# Move files to an other directory
if [ -z $mlop ]; then
mlop=n
fi
while [ $mlop != "y" ];
do
echo -n "Would you move all jpg files to $TITLE directory ? (y/n): "
read op
mlop=`echo $op | tr [A-Z] [a-z]`
if [ $mlop = "n" ]; then
break
fi
done
if [ $mlop = "y" ]; then
mkdir $WDIR/$TITLE
for FILE in `ls *.jpg`
do
echo "Moving: $FILE..."
mv $FILE $TITLE/
done
echo "All files were moved with sucess. Done"
mv $WDIR/$TITLE/ $ABDIR/
fi
################################################
Script para sincronizar dados entre desktop e notebook de maneira 99% automática usando rsync
shieldscript - Script para defesa básica do seu GNU/Linux
Nenhum comentário foi encontrado.
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o sábado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Novos apps de produtividade, avanços em IA e distros em ebulição agitam o universo Linux
Como instalar o repositório do DBeaver no Ubuntu
Como instalar o Plex Media Server no Ubuntu
Digitando underscore com "shift" + "barra de espaços"
Como ativar a lixeira e recuperar aquivos deletados em um servidor Linux
Como mudar o nome de dispositivos Bluetooth via linha de comando
Programa fora de escala na tela do pc (10)
Fedora KDE plasma 42 X Módulo de segurança BB (Warsaw-2) (1)
O programa assinador digital (1)









