Skip to content

Instantly share code, notes, and snippets.

@temberature
Last active September 4, 2019 10:22
Show Gist options
  • Save temberature/3314cc006e3279a416b8e4a0372d89c9 to your computer and use it in GitHub Desktop.
Save temberature/3314cc006e3279a416b8e4a0372d89c9 to your computer and use it in GitHub Desktop.
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
src="/volume1/homes/1605259395"
dst="/volume1/books"
echo $src
function read_dir() {
for file in $(#
ls $1
); do
echo "-->"$file
if [ -d $1"/"$file ]; then
read_dir $1"/"$file
elif [[ -f $1"/"$file && (${file: -4} == ".pdf" || ${file: -5} == ".epub" || ${file: -5} == ".azw3" || ${file: -5} == ".mobi") ]]; then # ||cp base file to dst file
echo $1$"/"$file
[ $(mv -vn "$1""/""$file" $dst) ]
else
echo ".."
fi
done
}
read_dir $src
echo "successful!"
echo $1" "$2
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment