[PLUG] Script Help

Michael Barnes barnmichael at gmail.com
Mon Dec 21 03:33:51 UTC 2020


On Sun, Dec 20, 2020 at 6:44 PM Ali Corbin <ali.corbin at gmail.com> wrote:

> On Sun, Dec 20, 2020 at 6:38 PM Michael Barnes <barnmichael at gmail.com>
> wrote:
>
> > Sad thing about getting old. Memory ain't what it used to be.
> >
> > About 15 years or so ago, I wrote a script to trim filenames. What I did
> > with the script  was to download a group of files from an ftp site to a
> > folder. The files were named something like
> >
> > ABC 12-12-20 TodayShow.mp3
> >
> > The "TodayShow" was different for each file. I needed to remove
> everything
> > after the date, rename the file and move it to another folder.
> >
> > The trimming portion of the script was
> > cd /home/Xfer/downloads
> > for FILE in *.mp3; do mv "$FILE" "$(echo "$FILE"|tr ' ' '_')"; done
> > for FILE in *.mp3; do mv "$FILE" ${FILE%%???????.mp3}.mp3; done
> >
> > I need to update this script for a similar purpose. I just can't remember
> > exactly how this works. Would someone mind please translating or
> explaining
> > this to me so I can modify it?
> >
> >
> > The first line renames every file to the same name, but with all of its
> spaces translated into underbars.
> The second one strips off the .mp3 and the six characters before it, and
> replaced it with a bare .mp3.
>

Thank you very much.

Michael



More information about the PLUG mailing list