mirror of
https://github.com/km4ack/pi-display
synced 2026-08-13 17:58:24 -04:00
47 lines
No EOL
1.2 KiB
Bash
Executable file
47 lines
No EOL
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
HEADER(){
|
|
clear;echo;echo
|
|
echo "############################"
|
|
echo "# Pi-Display File Importer #"
|
|
echo "############################"
|
|
}
|
|
if [ -z "$1" ]; then
|
|
echo "no import directory specified. usage is"
|
|
echo "import /path/to/import/dir"
|
|
exit 1
|
|
fi
|
|
|
|
import_dir=$1
|
|
export=$HOME/pi-display/files
|
|
|
|
ck=$(ls $import_dir)
|
|
if [ -z "$ck" ]; then
|
|
echo ":::: CRITICAL ERROR! ::::"
|
|
echo "Directory selected for import seems to be"
|
|
echo "empty or not found. Can't continue"
|
|
exit 1
|
|
fi
|
|
|
|
HEADER
|
|
echo "Files from $import_dir will be imported"
|
|
echo "If this is wrong, press ctrl+c to stop and exit"
|
|
echo
|
|
echo "The time a file is displayed can be adjusted after"
|
|
echo "import in the $HOME/pi-display/links file"
|
|
read -p "How many seconds to display each file? " sec
|
|
HEADER
|
|
echo "File will be imported into a subdirectory"
|
|
echo "of $export"
|
|
read -p "Please give the sub directory a name? " dir
|
|
dir=$(echo $dir | sed 's/ /-/g')
|
|
mkdir -p $HOME/pi-display/files/$dir
|
|
HEADER
|
|
|
|
for file in $import_dir/*; do
|
|
mv $file ${export}/${dir}
|
|
filename=$(echo $file | awk -F "/" '{print $NF}')
|
|
echo "importing $filename to display for $sec seconds"
|
|
echo "/${dir}/${filename},${sec}" >> $HOME/pi-display/links
|
|
done
|
|
echo "Import complete. Files added to slideshow." |