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 6743519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:58:13+00:00 2026-05-26T11:58:13+00:00

I got help regarding the following question: batch rename files with ids intact It’s

  • 0

I got help regarding the following question:
batch rename files with ids intact

It’s a great example of how to rename specific files in a group, but I am wondering if there is a similar script I could use to do the following:

  1. I have a group of nested folders and files within a root directory that contain [myprefix_foldername] and [myprefix_filename.ext]
  2. I would like to rename all of the folders and files to [foldername] and [filename.ext]

Can I use a similar methodology to what is found in the post above?

Thanks!
jml

  • 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-26T11:58:14+00:00Added an answer on May 26, 2026 at 11:58 am

    Yes, quite easily, with find.

    find rootDir -name "myprefix_*"
    

    This will give you a list of all files and folders in rootDir that start with myprefix_. From there, it’s a short jump to a batch rename:

    find rootDir -name "myprefix_*" | while read f
    do
      echo "Moving $f to ${f/myprefix_/}"
      mv "$f" "${f/myprefix_/}"
    done
    

    EDIT: IFS added per http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

    EDIT 2: IFS removed in favor of while read.

    EDIT 3: As bos points out, you may need to change while read f to while read -d $'\n' f if your version of Bash still doesn’t like it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got great help in my first question n hopefully someone will tell me
I've got some batch files that I use to help automate the process of
I have a question regarding string modification. Let's assume that we have the following
I've got a question regarding Map/Reduce Sort an inner Document in mongodb. The scheme
I got a question regarding C++ Object & Javascript Object life cycle mis-synchronization and
I got help with correct calculation the other day but I've hit a block
I just got help in how to compile this script a few mintues ago
can anybody help me solve this : i got $filename= index 198.php; i use
I'm in need of help - I've got two mysql databases on different servers
I've got a string Purchases 10384839,Purchases 10293900,Purchases 20101024 Can anyone help me with parsing

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.