Rename all files to lowercase?

C

Charles1718

Guest
Hi People,

I'm currently trying to Rename all files with .txt to lowercase with this commands below

PHP:
for tup in find *.txt
do 
tup_file=$tup 
tow_file="echo $tup | tr [A-Z] [a-z]" 
mv $tup_file $tow_file 
done

But somehow I always get this error Message "mv 'a-z' is not a Directory" ?? :confused:

Thanks in Advance!
Charles
 


Hi People,

I'm currently trying to Rename all files with .txt to lowercase with this commands below

PHP:
for tup in find *.txt
do 
tup_file=$tup 
tow_file="echo $tup | tr [A-Z] [a-z]" 
mv $tup_file $tow_file 
done

But somehow I always get this error Message "mv 'a-z' is not a Directory" ?? :confused:

Thanks in Advance!
Charles
Here's a one-liner I wrote and tested:
Code:
for tup in `find . -iname *.txt`; do tup_file=$tup && tow_file=`echo "$tup" | tr [A-Z] [a-z]` && echo "$tup -> $tow_file" && mv $tup_file $tow_file; done

I've used the same code as you, but there were some subtle differences. Probably the biggest issue with your code is that you quoted the "echo..." code. Instead, you have to have it executed. Besides that, you missed the "execute command" part in the for loop as well. I hope this helps you!

Oh, and to show it works:
Code:
ehansen@desktop:~# touch TESTING.txt
ehansen@desktop:~# ls -liha
total 0 KB
22413323 drwxr-xr-x  2 ehansen ehansen 4.0K 2012-01-31 19:01 .
22413315 drwxr-xr-x 26 ehansen ehansen 4.0K 2012-01-31 15:36 ..
22414780 -rw-r--r--  1 ehansen ehansen       0 2012-01-31 18:59 TESTING.txt
ehansen@desktop:~# for tup in `find . -iname *.txt`; do tup_file=$tup && tow_file=`echo "$tup" | tr [A-Z] [a-z]` && echo "$tup -> $tow_file" && mv $tup_file $tow_file; done
./TESTING.txt -> ./testing.txt
ehansen@desktop:~# ls -liha
total 0 KB
22413323 drwxr-xr-x  2 ehansen ehansen 4.0K 2012-01-31 19:01 .
22413315 drwxr-xr-x 26 ehansen ehansen 4.0K 2012-01-31 15:36 ..
22414780 -rw-r--r--  1 ehansen ehansen       0 2012-01-31 18:59 testing.txt
 
resolved

Thanks ehansen!

My issue is now resolved.

This one-liner Code works perfectly! :)

PHP:
for tup in `find . -iname *.txt`; do tup_file=$tup && tow_file=`echo "$tup" | tr [A-Z] [a-z]` && echo "$tup -> $tow_file" && mv $tup_file $tow_file; done

Thanks again,
Charles
 
This can't be fixed without just simply renaming the file in all lowercase? That's interesting. I would think that this wouldn't be too hard to do. Good luck with fixing this, though.
 
This can't be fixed without just simply renaming the file in all lowercase? That's interesting. I would think that this wouldn't be too hard to do. Good luck with fixing this, though.

I'm guessing you didn't actually read the thread all the way?
 
Hi People,

I'm currently trying to Rename all files with .txt to lowercase with this commands below

PHP:
for tup in find *.txt
do 
tup_file=$tup 
tow_file="echo $tup | tr [A-Z] [a-z]" 
mv $tup_file $tow_file 
done

But somehow I always get this error Message "mv 'a-z' is not a Directory" ?? :confused:

Thanks in Advance!
Charles

tow_file="echo $tup | tr [A-Z] [a-z]"
should instead be:
tow_file=`echo $tup | tr [A-Z] [a-z]`
OR:
tow_file=$(echo $tup | tr [A-Z] [a-z])



on a US keyboard the correct quote is in the upper right-hand corner.
 
I tried this method before. It can't handle filenames with spaces in them.
 

Members online


Latest posts

Top