Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:25:14+00:00 2026-05-18T01:25:14+00:00

I would like to run a bash script that recursively cleans up every filename

  • 0

I would like to run a bash script that recursively cleans up every filename in a directory. For example I have the filename:

The.Sarah.Jane.Adventures.S04E07.The.Empty.Planet.Part1.WS.PDTV.XviD-BiA.[sharethefiles.com].avi
The.Sarah.Jane.Adventures.S04E08.The.Empty.Planet.Part2.WS.PDTV.XviD-BiA.[sharethefiles.com].avi

I want to convert the file to:

The Sarah Jane Adventures S04E07 The Empty Planet Part1.avi

The Sarah Jane Adventures S04E07 The Empty Planet Part2.avi

So I have this sed script:

sed -e's/\[sharethefiles\.com\]//g; s/WS//g; s/PDTV//g; s/Xvid-BiA//g; s/XviD-BiA//g; s/\.\.//g; s/\./\ /g;'

but it comes with problems. The . (period) is removed before the suffix (avi) and I am not really sure how to replace it with files being so dynamic. Sometimes there maybe only one space before the suffix and sometimes there are none since the script also removes double periods.

Any ideas as to fixing the issue?

Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:25:15+00:00Added an answer on May 18, 2026 at 1:25 am

    You might want to convert all periods to spaces and then pipe into a command that sets the extension.

    Example (ignoring the other special cases you indicated):

    tr '.' ' ' | sed 's/ \([^ ]*\)$/.\1/'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a job through cron that will be executed every
I have a servlet that I would like to run within ColdFusion MX 7.
I have a console application that I would like to run as 'NT AUTHORITY\NetworkService',
I currently have a small Java program which I would like to run both
I would like to build an application that will run on a web, this
I have a long running BASH script that I am running under CYGWIN on
I would like to make sure that an applescript can be converted to bash.
I'm trying to write (what I thought would be) a simple bash script that
I have a bash script that cuts out a section of a logfile between
So I have a script that I want to run as root, without hangup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.