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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:14:42+00:00 2026-05-16T08:14:42+00:00

I have a folder with files named as input (1).txt input (2).txt input (3).txt

  • 0

I have a folder with files named as

input (1).txt
input (2).txt
input (3).txt
...
input (207).txt

How do I rename them to

input_1.in
input_2.in
input_3.in
...
input_207.in

I am trying this

for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done

But it gives me

mv: target `(100).txt' is not a directory
mv: target `(101).txt' is not a directory
mv: target `(102).txt' is not a directory
...

Where did I go wrong?


I have put in the quotes now, but I get this now

mv: `input (90).txt' and `input (90).txt' are the same file

It is somehow trying to rename the file to the same name. How is that happening?

  • 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-16T08:14:43+00:00Added an answer on May 16, 2026 at 8:14 am

    That is because bash for split the element with space ‘ ‘ so you are commanding it to move ‘input‘ to ‘(1)‘.

    The way to solve this is to tell bash to split by new line using IFS variable.

    Like this:

    IFS=$'\n'

    Then do your command.

    However, I suggest you to use find to do this instead using -exec command.

    For example:

    find *.txt -exec mv "{}" `echo "{}" | sed -e 's/input\ (\([0-9]*\))\.txt/input_\1.in/'` \;

    NOTE: I write this from memory and I did test this so let try and adjust it.

    Hope this helps.

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

Sidebar

Related Questions

I have a folder in my app named Files. I would like to display
I have a folder with these files: alongfilename1.txt <--- created first alongfilename3.txt <--- created
I have a folder with two files: Awesome.File.20091031_123002.txt Awesome.File.Summary.20091031_123152.txt Additionally, a third-party app handles
I have some folder with different files. I want to use something like this:
I have a file named configuration.xml which resides in classes folder of my WEB-INF
I have a file watch directory named FileWatch C:\Users\MyFolder\FileWatch\Test The FileWatch folder is the
I have a folder with multiple files, and I'd like to remove all <script>
I have a folder full of files and I want to search some string
I have a folder with 2000+ files. I want to count the files by
I have a folder of PHP files. The source code to these files is

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.