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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:23:14+00:00 2026-05-27T05:23:14+00:00

After putting hours into this, I give up, and am asking for help. This

  • 0

After putting hours into this, I give up, and am asking for help. This has been answered perfectly in a previous SO question here: How do I rename all files to lowercase?

The trouble is, it does not work on Mac OS X. So I went about working to redo it so it would work. Learned a little about strong/weak quoting, which I thought had something to do with it. For now, I am using strong quoting on everything.

 #!/bin/bash
 echo ""; echo "Start run `basename $0` on `date`";
 echo "Script running from: `pwd`";

 # Change into the directory with the files to rename
 cd /Users/me/Desktop/files
 echo "Working on files in: `pwd`"; echo "";


 # Read in all files from a directory
 for file in *; do
      lowercase_filename=`echo $file | tr '[:upper:]' '[:lower:]'`;
      echo \'$file\' \'$lowercase_filename\';

      mv \'$file\' \'$lowercase_filename\';
      echo "--------------------";

 done

Here is what the above script will output when run:

 ./renamer.sh 

 Start run renamer.sh on Fri Nov 25 04:35:00 PST 2011
 Script running from: /Users/me/Desktop
 Working on files in: /Users/me/Desktop/files

 'This IS A test TEST.txt' 'this is a test test.txt'
 usage: mv [-f | -i | -n] [-v] source target
        mv [-f | -i | -n] [-v] source ... directory

For some reason, mv doesn’t work. However, what is strange, is if I take the debugging output and manually run this, it will work fine. So I have a before and and after string of a filename, in this case, the before is the mixed case and the after is the lowercase. The strings are quoted in single tic marks. I echo them out just as I would pass them as two args to the mv command.

'This IS A test TEST.txt' 'this is a test test.txt'

The script gives me an error, but if I run these commands by hand:

 # "l" is an alias for ls with some args to remove fot files 
 # and other junk I don't want to see.

 me@whitebook:\ $cd files
 me@whitebook:\ $l
 -rw-r--r--+  1 me  staff     0 Nov 25 03:49 This IS A test TEST.txt
 me@whitebook:\ $mv 'This IS A test TEST.txt' 'this is a test test.txt'
 me@whitebook:\ $l
 -rw-r--r--+  1 me  staff     0 Nov 25 03:49 this is a test test.txt

As you can see the file was renamed with lowercase just fine to “this is a test test.txt”. If I can mv these by hand, then something is happening inside the scripts environment that is getting it confused. Any idea what that may be?

I should be able to one-line this as the other poster has done, but no matter what I try, it doesn’t work for me.

Thanks for any guidance. I am on Mac OS X, here is some relevant system info…

$uname -a
Darwin whitebook.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:56:15 PDT 2011; root:xnu-1699.24.8~1/RELEASE_I386 i386


 $bash --version
 GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
 Copyright (C) 2007 Free Software Foundation, Inc.
  • 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-27T05:23:14+00:00Added an answer on May 27, 2026 at 5:23 am

    Can you try this?

    mv "$file" "$lowercase_filename";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started a new project this morning and, after putting ~3 hours of work
After reading this question , I was reminded of when I was taught Java
I've been working on this for a few hours now and can't find any
I have spent the last few hours putting togeather the following code after reading
There must be a simple solution to this, but after 4 hours of browsing
After some hours creating a vb.net helper class for unit-tests and integrating moq into
I putting wmd on my website. After putting code in and giving it a
what does putting () after a word do? sometimes it doesn't work
After hours of debugging, it appears to me that in FireFox, the innerHTML of
This may be a completely dumb question, but I've seen a couple examples declaring

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.