[GLLUG] Need help creating a shell Script

Caleb Cushing xenoterracide at gmail.com
Thu Apr 6 16:15:19 EDT 2006


I need/want to change the names of all the files and folders in my /music
directory to where they don't have spaces in them and all the names are in
lowercase. This is what I have so far:

#!/bin/bash

ls -R |                          # List directory recursively
sed -e 's/ /_/g' |             # Remove spaces change them to underscore
tr [:upper:] [:lower:] |     #change letters from upper to lower

that gives me the output of what I would want the directory and file
structure to look like when I'm done. I am unsure however how to take that
output and move the files and directories to acually look like that when I
am finished. It's also the tricky part because if I don't do it right...
well it might be an even bigger pain to fix. I pretty sure I have a lot more
to do to get this workable... and I'm just having problems wrapping my brain
around it.

snippet:before
#ls -R

./3 Doors Down:
Away from the Sun  Seventeen Days  The Better Life  Thumbs.db  desktop.ini

./3 Doors Down/Away from the Sun:
01-When I'm Gone-3 Doors Down-Away from the Sun.mp3
02-Away from the Sun-3 Doors Down-Away from the Sun.mp3
03-The Road I'm On-3 Doors Down-Away from the Sun.mp3
04-Ticket to Heaven-3 Doors Down-Away from the Sun.mp3
05-Running Out of Days-3 Doors Down-Away from the Sun.mp3
06-Here Without You-3 Doors Down-Away from the Sun.mp3
07-I Feel You-3 Doors Down-Away from the Sun.mp3
08-Dangerous Game-3 Doors Down-Away from the Sun.mp3
09-Changes-3 Doors Down-Away from the Sun.mp3
10-Going Down in Flames-3 Doors Down-Away from the Sun.mp3
11-Sarah Yellin'-3 Doors Down-Away from the Sun.mp3
AlbumArtSmall.jpg
AlbumArt_{C212FF41-147D-402C-BAC5-1284F8B4C802}_Large.jpg
AlbumArt_{C212FF41-147D-402C-BAC5-1284F8B4C802}_Small.jpg
Folder.jpg
Thumbs.db
desktop.ini

snippet:after

ls -R

./3_doors_down:
away_from_the_sun
seventeen_days
the_better_life
thumbs.db
desktop.ini

./3_doors_down/away_from_the_sun:
01-when_i'm_gone-3_doors_down-away_from_the_sun.mp3
02-away_from_the_sun-3_doors_down-away_from_the_sun.mp3
03-the_road_i'm_on-3_doors_down-away_from_the_sun.mp3
04-ticket_to_heaven-3_doors_down-away_from_the_sun.mp3
05-running_out_of_days-3_doors_down-away_from_the_sun.mp3
06-here_without_you-3_doors_down-away_from_the_sun.mp3
07-i_feel_you-3_doors_down-away_from_the_sun.mp3
08-dangerous_game-3_doors_down-away_from_the_sun.mp3
09-changes-3_doors_down-away_from_the_sun.mp3
10-going_down_in_flames-3_doors_down-away_from_the_sun.mp3
11-sarah_yellin'-3_doors_down-away_from_the_sun.mp3
albumartsmall.jpg
albumart_{c212ff41-147d-402c-bac5-1284f8b4c802}_large.jpg
albumart_{c212ff41-147d-402c-bac5-1284f8b4c802}_small.jpg
folder.jpg
thumbs.db
desktop.ini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.egr.msu.edu/mailman/public/linux-user/attachments/20060406/68eb92e3/attachment.html


More information about the linux-user mailing list