Link to home
Start Free TrialLog in
Avatar of Michael Smith
Michael SmithFlag for Ireland

asked on

Scripting issue to rename a file.......

A personal issue at home with my media section.

I have a script that moves my content into its own folder......


#!/bin/bash
find . -type f ! -name "*script*" | while read file;
do
    f=$(basename "$file")
    f1=${f%.*}
    mkdir "$f1"
    mv "$f" "$f1"
done

I would like to modify the script ...
Imagine I have 4 files in a directory - Every files has " - S"*****************
NameOfShow -SXXEXX - Description
NameOfShow1 - SXXEXX - Description 1
NameOfShow 2 - SXXEXX - Description 2
NameOfShow 3 - SXXEXX - Description 3

I run the script - I would like to remove everything after the NameOfShow" - S*"
Files should become:
NameOfShow
NameOfShow1
NameOfShow2
NameOfShow3
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michael Smith

ASKER

ozo - Perfect~!!

Sorry for the delay!