Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question Rename all files to lowercase in a specified diretory?

    Hi People,

    I'm currently trying to Rename all files with .txt in a specified directory to lowercase, with this commands below:

    PHP Code:
    for tup in find *.txt
    ="echo $tup | tr [A-Z] [a-z]" 
    mv $tup_file $tow_file 
    But somehow I always get this error Message "mv 'a-z' is not a Directory" ??

    Thanks in Advance!
    Last edited by Charles1718; 01-31-2012 at 05:14 PM. Reason: wrong spelling

  2. #2
    Just Joined!
    Join Date
    Dec 2011
    Doing this off the top of my head, but any chance you really want to use `backticks` with your tow_file line to get the results of the output? Right now tow_file is being assigned that whole string, right?

  3. #3
    yeah, frat is right about the backticks.

    also, i assume you left out the backticks on your find command in the code you posted, as it won't work as it. in any case, you don't need the find, you can more efficiently achieve the same list of txt files with a simple file glob, e.g.:

    for file in *.txt; do
    also, note that your code won't work as is if your files have white spaces in them.

  4. $spacer_open
  5. #4
    for tup in `find *.txt`; do tup_file=$tup ; tow_file=`echo $tup | tr [A-Z] [a-z]` ; mv $tup_file $tow_file ; done

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts