Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a bunch of config files that I'd like to store elsewhere, but if I move them and then symlink the directory, the application sees it as a symlink and won't use the contained files.

Instead what I'd like to do is figure out a command that would allow me to batch-create symlinks for all of the files within a given directory. Can this be done?

share|improve this question
up vote 7 down vote accepted

Just use a wildcard. Like this:

ln -s /path/to/config/files/* /path/to/symlinks/

While you can use a relative path for the destination directory, the directory the link targets are in must be specified with an absolute path.

Note that if there are any directories in the directory with the targets, it will make a symlink to it instead of creating a directory with symlinks inside. If there are too many (if any at all) to work around manually you'd have to write a shell script to accomplish this.

share|improve this answer
If you have too many files look into the "xargs" command. – Chris Nava Mar 6 '11 at 22:36
Wow, now I feel silly for asking! Simple, elegant, and probably something I could have guessed in about 10 minutes! Thanks! – Wilco Mar 6 '11 at 23:13
@Wilco: We all have those moments. Rubber ducky debugging anyone?? – surfasb Jan 17 '12 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .