Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
0fb7c7fde8 | |||
246f25600e | |||
ad32f12055 | |||
5be6d0ec88 | |||
458345c79c | |||
|
80150201fe | ||
|
e68fef7879 | ||
|
07a7680df8 | ||
|
dd2cfa7999 | ||
|
f1ce8b6894 | ||
|
153cc41e02 |
5 changed files with 69 additions and 70 deletions
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
LICENSE
Normal file → Executable file
0
LICENSE
Normal file → Executable file
69
README.md
Normal file → Executable file
69
README.md
Normal file → Executable file
|
@ -1,41 +1,43 @@
|
||||||

|
# WPFind
|
||||||
|
|
||||||
WPFind
|

|
||||||
======
|
|
||||||
|
|
||||||
The purpose of this script is to find wallpapers among pictures files in directory and sub-directories and move/copy them to a separate directory.
|
The purpose of this script is to find wallpapers among pictures files in directory and sub-directories and move/copy them to a separate directory.
|
||||||
It can be useful when you are trying to clean your mess on your computer ;-)
|
It can be useful when you are trying to clean your mess on your computer ;-)
|
||||||
|
|
||||||
Requirements
|
## Requirements
|
||||||
------------
|
|
||||||
|
|
||||||
* Ubuntu, Linux Mint (should work on other Ubuntu derivatives)
|
- Ubuntu, Linux Mint (should work on Ubuntu derivatives), Arch Linux (should work on Ubuntu derivatives) and probably any Linux distro
|
||||||
* detox
|
- detox
|
||||||
* imagemagick
|
- imagemagick
|
||||||
|
|
||||||
Installation
|
## Installation
|
||||||
------------
|
|
||||||
|
|
||||||
For Ubuntu 16.04, Linux Mint 18.x, and other derivatives
|
|
||||||
|
|
||||||
```
|
|
||||||
curl -L https://packagecloud.io/makoto/stable/gpgkey | sudo apt-key add -
|
|
||||||
echo "deb https://packagecloud.io/makoto/stable/ubuntu/ xenial main" | sudo tee /etc/apt/sources.list.d/makoto.list
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install wpfind
|
|
||||||
```
|
|
||||||
|
|
||||||
For Ubuntu 18.04, Linux Mint 19.x, and other derivatives
|
For Ubuntu 18.04, Linux Mint 19.x, and other derivatives
|
||||||
|
|
||||||
```
|
```shell
|
||||||
curl -L https://packagecloud.io/makoto/stable/gpgkey | sudo apt-key add -
|
curl -L https://packagecloud.io/makoto/stable/gpgkey | sudo apt-key add -
|
||||||
echo "deb https://packagecloud.io/makoto/stable/ubuntu/ bionic main" | sudo tee /etc/apt/sources.list.d/makoto.list
|
echo "deb https://packagecloud.io/makoto/stable/ubuntu/ bionic main" | sudo tee /etc/apt/sources.list.d/makoto.list
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install wpfind
|
sudo apt-get install wpfind
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage options
|
For Ubuntu 20.04, Linux Mint 20.x, and other derivatives
|
||||||
-------------
|
|
||||||
|
```shell
|
||||||
|
curl -L https://packagecloud.io/makoto/stable/gpgkey | sudo apt-key add -
|
||||||
|
echo "deb https://packagecloud.io/makoto/stable/ubuntu/ focal main" | sudo tee /etc/apt/sources.list.d/makoto.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install wpfind
|
||||||
|
```
|
||||||
|
|
||||||
|
For Arch Linux and derivatives
|
||||||
|
|
||||||
|
```shell
|
||||||
|
yay -S wpfind
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage options
|
||||||
|
|
||||||
```
|
```
|
||||||
██╗ ██╗██████╗ ███████╗██╗███╗ ██╗██████╗
|
██╗ ██╗██████╗ ███████╗██╗███╗ ██╗██████╗
|
||||||
|
@ -47,7 +49,7 @@ Usage options
|
||||||
|
|
||||||
Find wallpapers recursively in a dir and sub-directories...
|
Find wallpapers recursively in a dir and sub-directories...
|
||||||
|
|
||||||
Version : 0.1.2
|
Version : 0.1.3
|
||||||
Author : Francois B (Makoto)
|
Author : Francois B (Makoto)
|
||||||
Licence : GPLv3
|
Licence : GPLv3
|
||||||
|
|
||||||
|
@ -62,36 +64,33 @@ Usage : wpfind [options]
|
||||||
-h : show help & informations
|
-h : show help & informations
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage examples
|
## Usage examples
|
||||||
--------------
|
|
||||||
|
|
||||||
Copy wallpapers in the current directory and sub-directories with minimum width of 1920px to wpfiles
|
Copy wallpapers in the current directory and sub-directories with minimum width of 1920px to wpfiles
|
||||||
|
|
||||||
```
|
```shell
|
||||||
wpfind -c
|
wpfind -c
|
||||||
```
|
```
|
||||||
|
|
||||||
Move wallpapers in the current directory and sub-directories with minimum width of 1920px to wpfiles
|
Move wallpapers in the current directory and sub-directories with minimum width of 1920px to wpfiles
|
||||||
|
|
||||||
```
|
```shell
|
||||||
wpfind -m
|
wpfind -m
|
||||||
```
|
```
|
||||||
|
|
||||||
Move wallpapers in the /home/user/MyPics directory and sub-directories with minimum width of 2560px to /home/user/MyWP directory
|
Move wallpapers in the /home/user/MyPics directory and sub-directories with minimum width of 2560px to /home/user/MyWP directory
|
||||||
|
|
||||||
```
|
```shell
|
||||||
wpfind -m -w 2560 -i /home/user/MyPics -o /home/user/MyWP
|
wpfind -m -w 2560 -i /home/user/MyPics -o /home/user/MyWP
|
||||||
```
|
```
|
||||||
|
|
||||||
Credits
|
## Credits
|
||||||
-------
|
|
||||||
|
|
||||||
This script has been written by Francois B. (Makotosan/Shakasan)
|
This script has been written by Francois B. (Makotosan/Shakasan)
|
||||||
|
|
||||||
* Email : francois@makotonoblog.be
|
- Email : francois@exoseed.be
|
||||||
* Website : https://makotonoblog.be/wpfind/
|
- Website : https://makotonoblog.be/wpfind/
|
||||||
|
|
||||||
Licence
|
## Licence
|
||||||
-------
|
|
||||||
|
|
||||||
The script is licensed under the terms of the GPLv3
|
The script is licensed under the terms of the GPLv3
|
||||||
|
|
0
pics/logo.png
Normal file → Executable file
0
pics/logo.png
Normal file → Executable file
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
70
wpfind
70
wpfind
|
@ -7,7 +7,7 @@
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# app version number
|
# app version number
|
||||||
version="0.1.3"
|
version="0.1.3.2"
|
||||||
# logfile
|
# logfile
|
||||||
logfile="wpfind.log"
|
logfile="wpfind.log"
|
||||||
touch $logfile
|
touch $logfile
|
||||||
|
@ -56,7 +56,7 @@ function logo() {
|
||||||
printf " ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ \n";
|
printf " ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ \n";
|
||||||
printf "$BOLDVERT";
|
printf "$BOLDVERT";
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "Find wallpapers recursively in a dir and sub-directories...\n"
|
printf "Find wallpapers recursively in a dir and sub-directories...\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "$NORMAL"
|
printf "$NORMAL"
|
||||||
printf "Version : $version\n"
|
printf "Version : $version\n"
|
||||||
|
@ -78,7 +78,7 @@ function usage() {
|
||||||
printf " -o <wallpapers_found_save_directory> (default: wpfiles inside the current directory)\n"
|
printf " -o <wallpapers_found_save_directory> (default: wpfiles inside the current directory)\n"
|
||||||
printf " -w <minimum_pixel_width> (default: 1920px)\n"
|
printf " -w <minimum_pixel_width> (default: 1920px)\n"
|
||||||
printf " -v : verbose mode\n"
|
printf " -v : verbose mode\n"
|
||||||
printf " -h : show help & informations\n"
|
printf " -h : show help & informations\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -129,47 +129,47 @@ function wpFind () {
|
||||||
# browse recursively files and dir
|
# browse recursively files and dir
|
||||||
for pic in $1/*; do
|
for pic in $1/*; do
|
||||||
# if directory
|
# if directory
|
||||||
if [ -d "$pic" ]; then
|
if [ -d "$pic" ]; then
|
||||||
# and if not outputDir
|
# and if not outputDir
|
||||||
if [ "$pic" != "$outputDirToCheck" ]; then
|
if [ "$pic" != "$outputDirToCheck" ]; then
|
||||||
# browse sub-dir
|
# browse sub-dir
|
||||||
wpFind "$pic"
|
wpFind "$pic"
|
||||||
fi
|
fi
|
||||||
# if file
|
# if file
|
||||||
elif [ -f "$pic" ]; then
|
elif [ -f "$pic" ]; then
|
||||||
# if file type is a picture
|
# if file type is a picture
|
||||||
if [[ $(file --mime-type -b "$pic") == image/*g ]]; then
|
if [[ $(file --mime-type -b "$pic") == image/*g ]]; then
|
||||||
pic_w_size=$(identify -format %w $pic)
|
pic_w_size=$(identify -format %w $pic)
|
||||||
pic_h_size=$(identify -format %h $pic)
|
pic_h_size=$(identify -format %h $pic)
|
||||||
# if picture width > height
|
# if picture width > height
|
||||||
if [ "$pic_w_size" -gt "$pic_h_size" ]; then
|
if [ "$pic_w_size" -gt "$pic_h_size" ]; then
|
||||||
# if picture width <= minimum width
|
# if picture width <= minimum width
|
||||||
if [ "$pic_w_size" -gt "$(($minw-1))" ]; then
|
if [ "$pic_w_size" -gt "$(($minw-1))" ]; then
|
||||||
# if copy mode
|
# if copy mode
|
||||||
if [ "$pic2move" = "no" ]; then
|
if [ "$pic2move" = "no" ]; then
|
||||||
# if verbose mode
|
# if verbose mode
|
||||||
if [ "$verbosemode" = "yes" ]; then
|
if [ "$verbosemode" = "yes" ]; then
|
||||||
printf "cp $iMode $pic $outputDir\n"
|
printf "cp $iMode $pic $outputDir\n"
|
||||||
fi
|
fi
|
||||||
cp $iMode $pic $outputDir
|
cp $iMode "$pic" "$outputDir"
|
||||||
date2log=$($date +'%Y-%m-%d %H:%M:%S')
|
date2log=$($date +'%Y-%m-%d %H:%M:%S')
|
||||||
printf "$date2log - cp $iMode $pic $outputDir\n" >> $logfile
|
printf "$date2log - cp $iMode $pic $outputDir\n" >> $logfile
|
||||||
# if move mode
|
# if move mode
|
||||||
elif [ "$pic2move" = "yes" ]; then
|
elif [ "$pic2move" = "yes" ]; then
|
||||||
# if verbose mode
|
# if verbose mode
|
||||||
if [ "$verbosemode" = "yes" ]; then
|
if [ "$verbosemode" = "yes" ]; then
|
||||||
printf "mv $iMode $pic $outputDir\n"
|
printf "mv $iMode $pic $outputDir\n"
|
||||||
fi
|
fi
|
||||||
mv $iMode $pic $outputDir
|
mv $iMode "$pic" "$outputDir"
|
||||||
date2log=$($date +'%Y-%m-%d %H:%M:%S')
|
date2log=$($date +'%Y-%m-%d %H:%M:%S')
|
||||||
printf "$date2log - mv $iMode $pic $outputDir\n" >> $logfile
|
printf "$date2log - mv $iMode $pic $outputDir\n" >> $logfile
|
||||||
fi
|
fi
|
||||||
picmoved=$(($picmoved+1))
|
picmoved=$(($picmoved+1))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -177,9 +177,9 @@ function wpFind () {
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
function main() {
|
function main() {
|
||||||
beginProcess=$($date +'%s')
|
beginProcess=$($date +'%s')
|
||||||
printf "$NORMAL""Analyzing...(this may take a (very)(long) while)\n""$NORMAL"
|
printf "$NORMAL""Analyzing...(this may take a (very)(long) while)\n""$NORMAL"
|
||||||
|
|
||||||
# check if detox is installed
|
# check if dependencies are installed
|
||||||
depInstalled
|
depInstalled
|
||||||
|
|
||||||
# create the outputDir if doesn't exist
|
# create the outputDir if doesn't exist
|
||||||
|
@ -205,7 +205,7 @@ function main() {
|
||||||
isValidDirectory $inputDir "i"
|
isValidDirectory $inputDir "i"
|
||||||
|
|
||||||
# some var init
|
# some var init
|
||||||
picmoved=0
|
picmoved=0
|
||||||
minw=$(($minw-1))
|
minw=$(($minw-1))
|
||||||
|
|
||||||
# begin the process
|
# begin the process
|
||||||
|
@ -213,18 +213,18 @@ function main() {
|
||||||
|
|
||||||
# display final status
|
# display final status
|
||||||
if [ "$pic2move" = "yes" ]; then
|
if [ "$pic2move" = "yes" ]; then
|
||||||
printf "$NORMAL""Pictures moved : ""$BOLDVERT""$picmoved\n""$NORMAL"
|
printf "$NORMAL""Pictures moved : ""$BOLDVERT""$picmoved\n""$NORMAL"
|
||||||
elif [ "$pic2move" = "no" ]; then
|
elif [ "$pic2move" = "no" ]; then
|
||||||
printf "$NORMAL""Pictures copied : ""$BOLDVERT""$picmoved\n""$NORMAL"
|
printf "$NORMAL""Pictures copied : ""$BOLDVERT""$picmoved\n""$NORMAL"
|
||||||
fi
|
fi
|
||||||
# display additional informations with the status
|
# display additional informations with the status
|
||||||
if [ "$verbosemode" = "yes" ]; then
|
if [ "$verbosemode" = "yes" ]; then
|
||||||
printf "$NORMAL""Minimal width : $(($minw+1))\n""$NORMAL"
|
printf "$NORMAL""Minimal width : $(($minw+1))\n""$NORMAL"
|
||||||
printf "$NORMAL""Logfile : wpfind.log\n""$NORMAL"
|
printf "$NORMAL""Logfile : wpfind.log\n""$NORMAL"
|
||||||
printf "$NORMAL""Analyzed dir : $inputDir\n""$NORMAL"
|
printf "$NORMAL""Analyzed dir : $inputDir\n""$NORMAL"
|
||||||
printf "$NORMAL""Wallpapers dir : $outputDir\n""$NORMAL"
|
printf "$NORMAL""Wallpapers dir : $outputDir\n""$NORMAL"
|
||||||
fi
|
fi
|
||||||
printf "\n" >> $logfile
|
printf "\n" >> $logfile
|
||||||
|
|
||||||
# display the time elapsed for the complete process
|
# display the time elapsed for the complete process
|
||||||
endProcess=$($date +'%s')
|
endProcess=$($date +'%s')
|
||||||
|
@ -237,11 +237,11 @@ function main() {
|
||||||
[[ $# -lt 1 ]] && logo && usage && exit
|
[[ $# -lt 1 ]] && logo && usage && exit
|
||||||
|
|
||||||
while getopts ":c,m,h,v,s,i:,o:,w:" option; do
|
while getopts ":c,m,h,v,s,i:,o:,w:" option; do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
c)
|
c)
|
||||||
pic2move=no
|
pic2move=no
|
||||||
;;
|
;;
|
||||||
m)
|
m)
|
||||||
pic2move=yes
|
pic2move=yes
|
||||||
;;
|
;;
|
||||||
o)
|
o)
|
||||||
|
@ -253,7 +253,7 @@ while getopts ":c,m,h,v,s,i:,o:,w:" option; do
|
||||||
w)
|
w)
|
||||||
minw=$OPTARG
|
minw=$OPTARG
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
logo
|
logo
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -261,7 +261,7 @@ while getopts ":c,m,h,v,s,i:,o:,w:" option; do
|
||||||
s)
|
s)
|
||||||
iMode="-i"
|
iMode="-i"
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
verbosemode=yes
|
verbosemode=yes
|
||||||
;;
|
;;
|
||||||
:)
|
:)
|
||||||
|
@ -269,12 +269,12 @@ while getopts ":c,m,h,v,s,i:,o:,w:" option; do
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
\?)
|
\?)
|
||||||
printf "$BOLDROUGE""Error""$NORMAL"" : $OPTARG : invalid option\n\n"
|
printf "$BOLDROUGE""Error""$NORMAL"" : $OPTARG : invalid option\n\n"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# if no mode choosed but other options set
|
# if no mode choosed but other options set
|
||||||
|
|
Loading…
Add table
Reference in a new issue