LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   symlink multiple files to new directory with new extension (https://www.linuxquestions.org/questions/linux-general-1/symlink-multiple-files-to-new-directory-with-new-extension-274647/)

jmanjohn61 01-06-2005 12:49 PM

symlink multiple files to new directory with new extension
 
I need to symlink multiple files to a different directory changing the extension of each file.
When I execute
ln -s /dir/*.123 /dir/*.321
I get
"ln: when making multiple links, last argument must be a directory"

What can I do to create a symlink of multiple files into a different directory changing the extension?

TX
John

Valindar 01-06-2005 12:55 PM

Code:

#!/bin/bash

for file in /dir/*.123 ; do
  ln -s $file `echo $file | sed 's/123$/321/'`
done

I haven't tested it but it should work no probs! Just make sure you change the right things in it :) (if you wanted to change mp3 to ogg you'd change s/123$/321/ to s/mp3$/ogg/ and /dir/*.123 to /dir/*.mp3)

edit: added code tags, whoops! :)


All times are GMT -5. The time now is 05:26 PM.