How to use /etc/paths.d to add executable files to my path? I am trying to use /etc/paths.d to add an executable to my path variable but I have no success so far.

The full path of the executable file is: /opt/ImageMagick/bin/convert

/etc/paths.d contains two files: 40-XQuartz and ImageMagick

The 40-XQuartz contains one line: /opt/X11/bin
The ImageMagick contains one line: /opt/ImageMagick/bin

My echo $PATH gives:

/Users/Administrator/.rbenv/shims:/Users/Administrator/.rbenv/bin:/Users/Administrator/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

So it seems that only the first file (40-XQuartz) does its job.
The permissions of the two files (40-XQuartz and ImageMagick) are exactly the same so my question is why the first one works and the second one is not.

I am running OS X Mavericks.
Have you started a new login shell since adding the new file for ImageMagick? The setting of the path from paths.d entries is done in /etc/profile and /etc/csh.login, so you need to start a new shell for the new entries to take effect.

OS X uses path_helper to set the path based on the files in /etc/paths.d - you can always call it manually (assuming a Bourne-like shell here):

$ eval `/usr/libexec/path_helper -s`