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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:15:25+00:00 2026-05-28T05:15:25+00:00

I have a directory structure as follows dir—-| | |–dir1\ some\ thing–result.pdf | |–dir2\

  • 0

I have a directory structure as follows

dir----|
       |
       |--dir1\ some\ thing--result.pdf
       |
       |--dir2\ some\ thing--result.pdf
       |
       |--dir3\ some\ thing--result.pdf
       |

The file name in each subdirectory is result.pdf.

Where as directories dir1 dir2 dir3 have blank spaces in their name.
What I am not able to understand (I am writing a bash script) how do I take this directory name in variable and rename result.pdf

I want to rename each of this file result.pdf with same name as directory name.pdf

   #!/bin/bash
    for i in *;do
    cd $i
    mv result.pd $i.pdf
    cd ..
    done

blank spaces in directory names are creating problems.How to over come this?

  • 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-28T05:15:26+00:00Added an answer on May 28, 2026 at 5:15 am

    Try to quote the names:

    for i in *; do
      mv "$i/result.pdf" "$i/$i.pdf";
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I serve some static content in liferay? I have a directory structure
If i have the following directory structure: Project1/bin/debug Project2/xml/file.xml I am trying to refer
I have a directory structure as follows: | main.py | scripts |--| __init__.py |
I have a directory structure as follows: Projects -> Libraries -> Box2d -> Collision->
I have a simple python application where my directory structure is as follows: project/
I am really confused i have a directory structure as follows. /foo/bar/project/ under project
The directory and file structure is as follows: C:\xampp\htdocs\PHP_Upload_Image_MKDIR\uploaded C:\xampp\htdocs\testA.php // as follows $userID
I have a directory structure like the following; script.php inc/include1.php inc/include2.php objects/object1.php objects/object2.php soap/soap.php
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have a directory structure of directories and files that I want to render

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.