From 9aaeca58c4203bef185d9420eddeaa2b869cb46d Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Thu, 28 Nov 2024 18:39:21 +0100 Subject: [PATCH] feat: add script for sorting download and home foldeer --- scripts/sort_downloads.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/sort_downloads.sh diff --git a/scripts/sort_downloads.sh b/scripts/sort_downloads.sh new file mode 100755 index 0000000..71ae20e --- /dev/null +++ b/scripts/sort_downloads.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Function to sort files in a given directory +sort_files() { + local dir=$1 + cd "$dir" + + # Create directories if they do not exist + mkdir -p images videos documents + + # Move video files to the videos folder + mv *.webm *.mp4 *.mkv *.avi *.mov *.flv videos/ 2>/dev/null + + # Move image files to the images folder + mv *.png *.jpg *.jpeg *.gif *.webp *.bmp images/ 2>/dev/null + + # Move document files to the documents folder + mv *.pdf *.doc *.docx *.txt *.odt documents/ 2>/dev/null +} + +# Sort files in the Downloads folder +sort_files ~/Downloads + +# Sort files in the home folder +sort_files ~ \ No newline at end of file