I have a bunch of oggs in a partition called autotunes that are organized into directories by artist and then subdirectories by album. I am using ogg123 to play the files. As best I can tell, ogg123 does not have the ability to recursively select files from a nested directory structure. I need to have a symbolic link for each ogg appear in the /autotunes directory. I can get a list of all the oggs by just using locate *.ogg. I can dump that to a file with a redirection, but how can I use that file to create the symbolic links automatically? I assume that I'm needing to write a script to accomplish this task. I'm not at all familiar with perl, so I would prefer to use bash if possible. Does anyone have any pointers? I am somewhat familiar with bash scripting, but I'm a bit rusty so I could use a bit of a quick refresher if anyone has any links or advice to offer. Please don't suggest that I switch media players or anything of that sort. This is a music player for my car that has limited disk space that I want to conserve for the storage of the music. Thanks very much for any help you can offer. Have a great day. Rob
Hi,
On Mon, Jun 13, 2005 at 04:21:11PM -0500, Rob Becker wrote:
I have a bunch of oggs in a partition called autotunes that are organized into directories by artist and then subdirectories by album. I am using ogg123 to play the files. As best I can tell, ogg123 does not have the ability to recursively select files from a nested directory structure. I need to have a symbolic link for each ogg appear in the /autotunes directory. I can get a list of all the oggs by just using locate *.ogg. I can dump that to a file with a redirection, but how can I use that file to create the symbolic links automatically? I assume that I'm needing to write a script to accomplish this task. I'm not at
You don't need to dump the list to a file, just do the locate in the script. Sample bash script:
for ogg_file in $(locate *.ogg) do ln -s ${ogg_file} /dest/dir done
Or you could use find:
find /top/of/ogg/tree -name "*.ogg" -exec ln -s {} /dest/dir ;
On 6/13/05, Rob Becker [email protected] wrote:
I have a bunch of oggs in a partition called autotunes that are organized into directories by artist and then subdirectories by album.
I need to have a symbolic link for each ogg appear in the /autotunes directory. I can get a list of all the oggs by just using locate *.ogg. Others are much more qualified to answer this but here are my thoughts.
locate will return the file name. find will return the file name and the realative path example: find /music/oggfiles -iname '*.ogg' #all ogg files under /music/oggfiles
I would do something like: ++++++++++++++++++++++++++++++++++ #!/bin/sh cd /music/oggfles
for i in `find ./ -iname '*.ogg'` # note use of backtics do echo "working with $i" filename=`echo $i |sed 's/^.*///'` #strip the path echo "filename $filename" #make symbolic link in this directory ln -s $i $filename #lmake symb. links. done
+++++++++++++++++++++++++++++++++++++++++++++
Best of luck
On 4:21:11 pm 06/13/05 "Rob Becker" [email protected] wrote:
I have a bunch of oggs in a partition called autotunes that are organized into directories by artist and then subdirectories by album. I am using ogg123 to play the files. As best I can tell, ogg123 does not have the ability to recursively select files from a nested directory structure. I need to have a symbolic link for each ogg appear in the /autotunes directory. I can get a list of all the oggs by just using locate *.ogg. I can dump that to a file with a redirection, but how can I use that file to create the symbolic links automatically? I assume that I'm needing to write a script to accomplish this task. I'm not at all familiar with perl, so I would prefer to use bash if possible. Does anyone have any pointers? I am somewhat familiar with bash scripting, but I'm a bit rusty so I could use a bit of a quick refresher if anyone has any links or advice to offer. Please don't suggest that I switch media players or anything of that sort. This is a music player for my car that has limited disk space that I want to conserve for the storage of the music. Thanks very much for any help you can offer. Have a great day. Rob
How about this, from the top level dir where you want the symbolic links:
find -type f | xargs -I '{}' ln -s {} .
__ Jason Munro __ [email protected] __ http://hastymail.sourceforge.net/