- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Build a Smart File Organizer with Bash: Master If, For, & Case Statements
```
#!/bin/bash
# Create folders
mkdir -p Images Documents Videos Music Archives Others
# Loop through all files in current directory
for file in *; do
# Skip directories
[ -d "$file" ] && continue
case "${file##*.}" in
jpg|jpeg|png|gif|bmp|webp)
mv "$file" Images/
;;
pdf|doc|docx|txt|ppt|pptx|xls|xlsx)
mv "$file" Documents/
;;
mp4|mkv|avi|mov|flv)
mv "$file" Videos/
;;
mp3|wav|aac|flac)
mv "$file" Music/
;;
zip|tar|gz|rar|7z)
mv "$file" Archives/
;;
*)
mv "$file" Others/
;;
esac
done
echo "Files organized successfully!"
```
Is your downloads folder a graveyard of random PDFs, images, and .txt files? In this video, we’re building a Smart File Organizer that sorts your clutter automatically.
We’ll move past simple commands and dive into Bash Control Structures. You’ll learn how to use if-else statements to verify directories, for loops to iterate through hundreds of files in seconds, and the powerful case statement to route files to the right folders based on their extensions. We even cover "safety valves" like continue and break to handle empty files and emergency stops.
In this video, you will learn:
Directory Verification: Using if-else and [[ ]] to check if a path exists.
The For Loop: How to process every file in a directory systematically.
The Case Statement: A cleaner way to handle multiple file types (like .jpg or .txt).
Exception Handling: Using -s and continue to ignore empty files.
The "Kill Switch": Using the break command to stop a script instantly.
Full Automation: A quick look at using Cron Jobs to run your sorter on a schedule.
Video Timestamps
0:00 – The Problem: Manual sorting is a waste of time
0:17 – Goal: Building the Smart File Organizer
0:32 – Starting with the Shebang
0:54 – Gatekeeping with If-Else & Double Brackets [[ ]]
1:28 – Creating a Conveyor Belt with For Loops
1:58 – Routing files with Case Statements
2:28 – The common "Double Semicolon" (;;) mistake
2:41 – Skipping empty files with continue
2:53 – Using break as an emergency exit
3:11 – Testing the Smart Organizer
3:22 – Pro-Tip: Scheduling with Cron Jobs
#BashScripting #Automation #FileOrganizer #LinuxTips #DevOps #LearnToCode #SimpleLearn #ProgrammingBasics
Видео Build a Smart File Organizer with Bash: Master If, For, & Case Statements канала Simple Learn
#!/bin/bash
# Create folders
mkdir -p Images Documents Videos Music Archives Others
# Loop through all files in current directory
for file in *; do
# Skip directories
[ -d "$file" ] && continue
case "${file##*.}" in
jpg|jpeg|png|gif|bmp|webp)
mv "$file" Images/
;;
pdf|doc|docx|txt|ppt|pptx|xls|xlsx)
mv "$file" Documents/
;;
mp4|mkv|avi|mov|flv)
mv "$file" Videos/
;;
mp3|wav|aac|flac)
mv "$file" Music/
;;
zip|tar|gz|rar|7z)
mv "$file" Archives/
;;
*)
mv "$file" Others/
;;
esac
done
echo "Files organized successfully!"
```
Is your downloads folder a graveyard of random PDFs, images, and .txt files? In this video, we’re building a Smart File Organizer that sorts your clutter automatically.
We’ll move past simple commands and dive into Bash Control Structures. You’ll learn how to use if-else statements to verify directories, for loops to iterate through hundreds of files in seconds, and the powerful case statement to route files to the right folders based on their extensions. We even cover "safety valves" like continue and break to handle empty files and emergency stops.
In this video, you will learn:
Directory Verification: Using if-else and [[ ]] to check if a path exists.
The For Loop: How to process every file in a directory systematically.
The Case Statement: A cleaner way to handle multiple file types (like .jpg or .txt).
Exception Handling: Using -s and continue to ignore empty files.
The "Kill Switch": Using the break command to stop a script instantly.
Full Automation: A quick look at using Cron Jobs to run your sorter on a schedule.
Video Timestamps
0:00 – The Problem: Manual sorting is a waste of time
0:17 – Goal: Building the Smart File Organizer
0:32 – Starting with the Shebang
0:54 – Gatekeeping with If-Else & Double Brackets [[ ]]
1:28 – Creating a Conveyor Belt with For Loops
1:58 – Routing files with Case Statements
2:28 – The common "Double Semicolon" (;;) mistake
2:41 – Skipping empty files with continue
2:53 – Using break as an emergency exit
3:11 – Testing the Smart Organizer
3:22 – Pro-Tip: Scheduling with Cron Jobs
#BashScripting #Automation #FileOrganizer #LinuxTips #DevOps #LearnToCode #SimpleLearn #ProgrammingBasics
Видео Build a Smart File Organizer with Bash: Master If, For, & Case Statements канала Simple Learn
Комментарии отсутствуют
Информация о видео
16 апреля 2026 г. 9:09:15
00:03:39
Другие видео канала





















