File-Arranger Script i made

This forum is for all programming discussions. Not limited to just Linux-related discussions. We will not judge you based on the operating system or the programing language...unless it's Javascript. ;)
Post Reply
User avatar
Oddstap
Posts: 14
Joined: Fri Jan 24, 2020 12:37 am

File-Arranger Script i made

Post by Oddstap » Mon Mar 30, 2020 8:54 pm

Hello everyone i know i don't post here often but id like to share a script i wrote in bash along with someone else in an arch group on Facebook.
This script was written in bash and only has one dependency the inotify-tools package.
It's purpose is to organize files that are places in the ~/Downloads directory by file format.
I am by no means a programmer i am a novice who is self-studying C and Bash, my dream is to write fast, portable and optimized code.
I don't know how to use GitHub yet so please forgive any stupid mistakes here is a link let me know what you think.
~Thanks

https://github.com/oddstap/File-Arranger
Last edited by Oddstap on Mon Mar 30, 2020 9:06 pm, edited 1 time in total.

User avatar
DistroTube
Site Admin
Posts: 53
Joined: Thu Jan 02, 2020 1:12 am

Re: File-Arranger Script i made

Post by DistroTube » Mon Mar 30, 2020 9:03 pm

Ah, so you just run the script and it takes everything cluttering up your Downloads directory and puts them in the appropriate directories based on file extension? Very cool.

User avatar
Oddstap
Posts: 14
Joined: Fri Jan 24, 2020 12:37 am

Re: File-Arranger Script i made

Post by Oddstap » Mon Mar 30, 2020 9:10 pm

DistroTube wrote:
Mon Mar 30, 2020 9:03 pm
Ah, so you just run the script and it takes everything cluttering up your Downloads directory and puts them in the appropriate directories based on file extension? Very cool.
Hey DT bigfan and yeah, I originally did some messy stuff with it but i meet a cool old timer that helped me make it really clean. One of the biggest problems was the script was moving files before they were done downloading. The trick to fix this from my understanding is to check the file size and if its zero keep checking till its greater than zero. This allows the .part file or partially downloaded file(s) to finish downloading before moving.

User avatar
fossegrim
Posts: 38
Joined: Thu Jan 02, 2020 8:49 pm

Re: File-Arranger Script i made

Post by fossegrim » Mon Mar 30, 2020 11:27 pm

Good job.

Your GitHub usage seems all good. Aside from the initial one your commit messages are imperative which puts you ahead of a lot of developers already :D. Worry about branching and so on when you find the need for it. Pushing to master is good enough for simple projects.

When you are writing scripts longer than a few lines. I strongly suggest using a "proper" programming language for the task. For your script a language like Ruby or Python is much more appropriate. Whichever you choose it is miles better than shellscripting. With that said I recommend Ruby.
“Software is a gas; it expands to fill its container.”
— Nathan Myhrvold

Website: http://fossegr.im/
Shithub: https://github.com/olav35
Tweeter: https://twitter.com/olebullsplass

User avatar
Oddstap
Posts: 14
Joined: Fri Jan 24, 2020 12:37 am

Re: File-Arranger Script i made

Post by Oddstap » Tue Mar 31, 2020 4:58 pm

fossegrim wrote:
Mon Mar 30, 2020 11:27 pm
Good job.

Your GitHub usage seems all good. Aside from the initial one your commit messages are imperative which puts you ahead of a lot of developers already :D. Worry about branching and so on when you find the need for it. Pushing to master is good enough for simple projects.

When you are writing scripts longer than a few lines. I strongly suggest using a "proper" programming language for the task. For your script a language like Ruby or Python is much more appropriate. Whichever you choose it is miles better than shellscripting. With that said I recommend Ruby.
Hello, Thank you for your feedback. Why would shell-scripting be bad for things longer than a few lines?

User avatar
fossegrim
Posts: 38
Joined: Thu Jan 02, 2020 8:49 pm

Re: File-Arranger Script i made

Post by fossegrim » Thu Apr 02, 2020 2:33 pm

There is a lot to it and the best way to understand it is to learn and use a "real" language.

One problem with bash is that a lot of solutions therein are hackish and suboptimal. For instance bash has a serious lack of datatypes. Instead of having proper number datatypes like integers, floats, longints and doubles bash uses strings.
“Software is a gas; it expands to fill its container.”
— Nathan Myhrvold

Website: http://fossegr.im/
Shithub: https://github.com/olav35
Tweeter: https://twitter.com/olebullsplass

User avatar
fossegrim
Posts: 38
Joined: Thu Jan 02, 2020 8:49 pm

Re: File-Arranger Script i made

Post by fossegrim » Thu Apr 02, 2020 6:22 pm

If you decide to learn Ruby I highly recommend this book.

https://pine.fm/LearnToProgram/chap_00.html
“Software is a gas; it expands to fill its container.”
— Nathan Myhrvold

Website: http://fossegr.im/
Shithub: https://github.com/olav35
Tweeter: https://twitter.com/olebullsplass

Post Reply