RSSCategory: Coding

Is there a file in that folder?

If you need a script to find if there is a file in a folder or perhaps you are checking for the existence of a file in a specific location.

if [ -f $FILE]; then
echo “Yep that file is there
echo “Oh no file with that name found”


August 12, 2014 | By | Reply More

is that directory empty?

I needed a quick and dirty way to find if the contents of a directory is empty. I’m not interested in th hidden files only files or orther directories within. Here is the bash script i knocked up to do the check…

if[ “$(ls -A $DIRECTORY)”]; then
echo”$DIRECTORY is not empty!”
echo”$DIRECTORY is empty!”

Job done.

August 8, 2014 | By | Reply More

Adjusting the SUDO timeout

While the sudo flags are convenient, there may be times when you might forget to use these flags. Alternatively, you might wish to have the time-out be longer if you are not concerned about security and regularly find yourself needing to supply your password when running sudo commands. Therefore, you can change the default time-out for sudo to be shorter, longer, or even to disable it altogether and always require a password when running sudo.

To do this, you can specify a custom time-out by editing the sudo configuration file by opening the Terminal and then running the following procedure:

  1. Run the command “sudo visudo” to invoke the sudo configuration editor
  2. Press “i” to invoke “insertion mode” so you can make edits
  3. Use arrows to navigate to the section “# Defaults specification” which will have a number of lines that begin with “Defaults” below it.
  4. Change the line that states “Default env_reset” to have “,timestamp_timeout=NUMBER” (with NUMBER being the number of minutes to time-out) appended to it, so it reads like the following (in this example the number is 2 minutes—if you always want sudo to require a password then set this value to 0):Defaults env_reset,timestamp_timeout=2
  5. Press escape to exit insertion mode
  6. Press “:” followed by typing “w” then “q” and then press enter to save and quit

As always, before making any changes to system configuration files be sure to have a backup of your system (even though “visudo” will create an automatic backup of the sudoers file). To undo these changes, simply invoke the visudo editor again and remove these edits.


June 9, 2014 | By More


Filebot my new turn to tool for renaming various digital media, Moves & TV series etc. to a standardised format that Plex Media Server can add to my media centre. The very firts step is to download filebot from here – and install it. I’m using a Mac so dragging and dropping in to the Applications is the way to go.

Next we need to write the script. Simple and I used textedit and set it in to plain text mode by pressing ‘Command Shift & T’. Then copy and paste the code below in to thextedit. u will have to edit the “Path/to/Folder’ highligted below to point to your media folder, I set mine to /Volumes/media. Then save it as, well will do and I saved mine to ~/Documents/Scripts/

/Applications/ -script fn:amc --output "path/to/folder" --log-file amc.log --action copy --conflict override -non-strict --def artwork=y "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME"

Now we need to use terminal to make the script executable. Open terminal from the Applications/Utilities folder and at the command prompt type chmod u+x ~/Documents/Scripts/ this will set the executable bit.

Next make sure that Transmission know what to do when a torrent completes. Open Transmission’s Preferences, then navigate to ‘Transfers’ and click the Management tab. At the very bottom of this is check box labled ‘Call Script’ and use the chooser to open our script at ~/Documents/Scripts/

Now whenever a torrent is completed it should be renamed and copied in to the correct location ready to be indexed by Plex Media Server.

Check – the link for more information

June 8, 2014 | By More