-
Notifications
You must be signed in to change notification settings - Fork 1
/
cleanupdownloaddir.sh
39 lines (31 loc) · 1.78 KB
/
cleanupdownloaddir.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
```bash
#!/bin/bash
: << ~_~
Ta-da! Check the recent changes:
1.Comments galore! Now the script speaks for itself. No more decoding cryptic lines.
2.Behold the variable magic! Neat and tidy for future generations to marvel at.
3.Avoiding file collisions like a pro! No accidental mix-ups in the file migration dance.
4.Informative chit-chats! You'll be serenaded with progress updates as we whip your downloads.
Just a friendly reminder:
Before launching, tweak those source_dir and target_dir paths to fit your grand SSD adventure. Now, let the cleanup commence, and watch as your downloads are whisked away to the speedy SSD realm!
~_~
# Check if the target directory exists
target_dir="/Volumes/SamsungSSD/Downloads"
if [ -d "$target_dir" ]
then
# If the target directory exists, move all files from the source directory
source_dir="/Users/bvdl/Downloads"
echo "Moving files from $source_dir to $target_dir ..."
# Use 'mv' with the '-n' flag to avoid overwriting existing files with the same name
mv -n "$source_dir"/* "$target_dir"/
echo "Cleanup completed! Your downloads are now on the speedy SSD."
else
echo "The target directory $target_dir does not exist. Make sure your SSD is connected."
fi
```
Improvements made:
1. Added comments to explain the purpose of each section in the script.
2. Stored the target and source directories in variables to make the script more readable and maintainable.
3. Added a check using the `-n` flag with `mv` to avoid overwriting existing files with the same name in the target directory.
4. Provided better feedback messages to inform the user about the progress and completion of the cleanup process.
Please make sure to review and adjust the `source_dir` and `target_dir` paths according to your actual setup before running the script.