[GLLUG] Need help creating a shell Script

Caleb Cushing xenoterracide at gmail.com
Fri Apr 7 07:02:29 EDT 2006


I know it contains over 1000 not including directories and BS files I need
to remove I'm going to say over 1500.

On 4/6/06, Bruce Smith <blubdog at gmail.com> wrote:
>
> Just make a new directory and copy a few of your files there.  Then
> test it in the temporary directory before you run it in the real
> directory.
>
> How many files do you have in the real directory?  There is a limit on
> the size of the arguments you can have on a single command line, which
> may cause you problems.  There is a way around it; if you run into
> that problem let me know.
>
> - BS
>
>
> On 4/6/06, Caleb Cushing <xenoterracide at gmail.com> wrote:
> > haven't tried it yet backing up the directory into a tarball that'll
> take a
> > while. Do you think you could comment it for me? basically programming
> of
> > any kind is a weak point for me. I'm trying to improve. but copying and
> > pasting someone elses code may fix my issue but it won't fix my
> > understanding. "give a man a fish... teach a man to fish..." sort of
> thing.
> >
> >
> > On 4/6/06, Bruce Smith <blubdog at gmail.com> wrote:
> > > Disclaimer, backup the directory first!  :-)
> > > And copy/paste exactly!
> > >
> > > You can test without changing anything by adding an "echo" in front of
> > > the "mv" and optionally commenting out the "set" statements for better
> > > readability.
> > >
> > > One bug (feature?) is it will replace multiple spaces with only ONE
> > underscore.
> > >
> > > You need to run it with the filename(s) as arguments.  i.e.:
> > >   /path/to/scriptname *
> > >   /path/to/scriptname a*
> > >   /path/to/scriptname 'File to Test this  Thing on.TXT'
> > >
> > > - BS
> > >
> > >
> > > #!/bin/sh
> > > infile=upper
> > > outfile=lower
> > > for f
> > > do
> > >     if [ -f "$f" ]; then
> > >         l="$(echo $f|sed 's/ /_/g'|tr "[:${infile}:]"
> "[:${outfile}:]")"
> > >         if [ "$f" != "$l" ]; then
> > >             set -x
> > >             mv -i "$f" "$l"
> > >             set +x
> > >         fi
> > >      fi
> > > done
> > > # end of script
> > >
> > >
> > > On 4/6/06, Caleb Cushing < xenoterracide at gmail.com> wrote:
> > > > 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
> > > >
> > > > _______________________________________________
> > > > linux-user mailing list
> > > > linux-user at egr.msu.edu
> > > > http://mailman.egr.msu.edu/mailman/listinfo/linux-user
> > > >
> > > >
> > > >
> > >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.egr.msu.edu/mailman/public/linux-user/attachments/20060407/56206bff/attachment.html


More information about the linux-user mailing list