another shell script question!

This is a discussion about another shell script question! in the Linux Software category; hi! i have a dvd full of mp3 organized in \bandname\albumname\files. mp3 now i need a script which walks through this structure and creates in a dir on my hd anonymized links for example: band00x_album00x_00x i need this for accessing the whole files from MATLAB.

Linux Software 434 This topic was started by , . Last reply by ,


data/avatar/default/avatar12.webp

1 Posts
Location -
Joined 2004-01-24
hi!
 
i have a dvd full of mp3 organized in \bandname\albumname\files.mp3
now i need a script which walks through this structure and creates in a dir on my hd anonymized links for example: band00x_album00x_00x
i need this for accessing the whole files from MATLAB.
The problem i have is that the directory names on the dvd contain whitespaces.
If i do
 
for mydir in $(find -type d ); do
cd $mydir
...
done
 
 
it doesnt work because $mydir contains only the first silbling of a directory name containing spaces is used. (example dirname:"alice in chains", $mydir only contains "alice")
 
how do i get the full dirname?
or should i do the whole thing in a other way?
 
thanks for help
stefan

Participate in our website and join the conversation

You already have an account on our website? To log in, use the link provided below.
Login
Create a new user account. Registration is free and takes only a few seconds.
Register
This subject has been archived. New comments and votes cannot be submitted.
Jan 24
Created
Feb 28
Last Response
0
Likes
1 minute
Read Time
User User
Users

Responses to this topic


data/avatar/default/avatar32.webp

2 Posts
Location -
Joined 2004-02-27
I do some shell scripting from time to time in my job...
 
This problem didn't seem so hard until I tried to play with it a bit...but it was. It's quite hard to read into an array or otherwise do something so that the part of the path separated by a space isn't treated as a separated path.
 
Anyway, try something like this:
 
find $PWD -type d|{
while read aline;do
cd "$aline"
do-some-commands-here...
done }
 
That's a pipe symbol "|" after the "d" and before the "{" .
 
HTH.