Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:07+00:00 2026-06-09T13:15:07+00:00

I have a Ruby script that I wrote that sorts some files in a

  • 0

I have a Ruby script that I wrote that sorts some files in a jumble of directories based on it’s file extension. It would be very difficult to sort it using a GUI, and its easier for me to just put the file in the topmost directory and let the sorter do the work.

Problem is, I’m a bit of a noob to unix scripting. What I want to be able to do is be able to run that sorter script from anywhere on my computer, without having to

cd Desktop/Whatever/Foo
ruby sorterscript.rb

just write sortfolders at the commandline and have the program be run.

I’ve tested the script many times, and it works fine, I just want a bit more convenience.

Bonus: If possible, and not too difficult, it would be even better if I could have the program run, say, every hour automatically.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:15:08+00:00Added an answer on June 9, 2026 at 1:15 pm

    As far as your first question goes, you need to do couple of things:

    1. Add a shebang line to your script (make it the first line of the script):

      #!/usr/bin/ruby (or whatever the path to the Ruby interpreter’s executable is, I forget its exact location)

    2. Make the script executable, either via the Finder’s “Get Info” context menu, or via the command line, for example:

      chmod 755 my_script.rb

    3. Add the directory location of your script to the PATH environment variable to OS X’s launchd.conf file, as described here. You need to add this line:

      setenv PATH /path/to/my/script:$PATH (substitute the real path to your script)

    As far as your bonus question goes, you can use cron to set up a recurring job. I never really do this, but here’s Apple’s cron man page to get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i have ruby script that simply writes to a test.txt file with hello
I have created one ruby script that I want to run with some flags
I need to set up a cronjob that would run some ruby script on
I have Ruby script that creates a proxy so that I can make HTTP
I have a ruby script that opens a browser. I have it set to
I have a ruby script that does a few perforce operations (through the scripting
I have a ruby script that is simultaneously and asynchronously receiving and displaying messages
I have this ruby script that allows me to enter the name of a
I have a simple Ruby script that uses the rb-appscript gem to control iTunes,
I have a Ruby script (1.8.7) that sets up its own interactive shell for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.