Author Topic: Converting filenames to lowercase  (Read 792 times)

Agent007

  • Member
  • **
  • Posts: 120
  • Kudos: 0
Converting filenames to lowercase
« on: 29 May 2003, 16:46 »
Hi all,

Is it possible to convert multiple filenames in a directory to lowercase? how?

thanks,
007
AMD Athlon processor
256MB SDRAM
Linux Distro - RedHat 9.0

Faust

  • Member
  • **
  • Posts: 1,223
  • Kudos: 0
Converting filenames to lowercase
« Reply #1 on: 29 May 2003, 17:15 »
Try a shell script.  I'm guessing it would involve "for file in $1" and tr, but I'm not sure.  I would like to hear how you do it because I'm interested in a similar thing.  Also converting spaces to underscores would be good too.  ;)
Yesterday it worked
Today it is not working
Windows is like that
 -- http://www.gnu.org/fun/jokes/error-haiku.html

Pantso

  • Member
  • **
  • Posts: 1,249
  • Kudos: 55
    • http://www.support-freesoftware.org
Converting filenames to lowercase
« Reply #2 on: 30 May 2003, 03:11 »
Can you believe that I had a similar question myself? I think that a shell script would propably do the job as Faust wrote, but I really suck at shell scripting.   :rolleyes:  

So, if anyone has an answer to this, could you please share it with us?  

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
Converting filenames to lowercase
« Reply #3 on: 30 May 2003, 06:14 »
quote:
Originally posted by Faust:
Try a shell script.  I'm guessing it would involve "for file in $1" and tr, but I'm not sure.  I would like to hear how you do it because I'm interested in a similar thing.  Also converting spaces to underscores would be good too.   ;)  


for the underscore i believe something like:
ls | while read item; do mv "$item" `echo "$item" | sed 's/\ /_/g'`; done

might want to double check on the sed part, s and g might need to be reversed. it's been a while but that should work. for subdirectories you could do find instead of ls

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Converting filenames to lowercase
« Reply #4 on: 30 May 2003, 06:43 »
Code: [Select]

:-D
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

Agent007

  • Member
  • **
  • Posts: 120
  • Kudos: 0
Converting filenames to lowercase
« Reply #5 on: 31 May 2003, 21:56 »
There is a problem with the script if the directory name is in Uppercase. Is there another alternative?

thanks
AMD Athlon processor
256MB SDRAM
Linux Distro - RedHat 9.0

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Converting filenames to lowercase
« Reply #6 on: 1 June 2003, 21:05 »
Code: [Select]

Yup, just had to only make the conversions effect the last directory element  
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

Faust

  • Member
  • **
  • Posts: 1,223
  • Kudos: 0
Converting filenames to lowercase
« Reply #7 on: 1 June 2003, 13:12 »
Thanks for that all, now I can get onto prettying up all my files.      
With 85G+ i didn't really want to do all this by hand...  ;)
Yesterday it worked
Today it is not working
Windows is like that
 -- http://www.gnu.org/fun/jokes/error-haiku.html

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Converting filenames to lowercase
« Reply #8 on: 1 June 2003, 13:54 »
anytime  :D
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

Pantso

  • Member
  • **
  • Posts: 1,249
  • Kudos: 55
    • http://www.support-freesoftware.org
Converting filenames to lowercase
« Reply #9 on: 1 June 2003, 14:23 »
Excellent! Thanks Solo!      ;)

Agent007

  • Member
  • **
  • Posts: 120
  • Kudos: 0
Converting filenames to lowercase
« Reply #10 on: 1 June 2003, 20:26 »
hi!

The directory thing works now....but not the uppercase to lower case. Am attaching the output below....

 
quote:


mv: `/mnt/Setups/linux/window_managers/gkrellm/Acqua.gkrellm.tar.gz' and `/mnt/Setups/linux/window_managers/gkrellm/Acqua.gkrellm.tar.gz' are the same file

mv: `/mnt/Setups/linux/window_managers/gkrellm/CoplandOS.gkrellm.tar.gz' and `/mnt/Setups/linux/window_managers/gkrellm/CoplandOS.gkrellm.tar.gz' are the same file

mv: `/mnt/Setups/linux/window_managers/gkrellm/theme_MonkeyLovers.tar.gz' and `/mnt/Setups/linux/window_managers/gkrellm/theme_MonkeyLovers.tar.gz' are the same file




In the 1st case, Acqua hasnt changed
In the 2nd, CoplandOS hasnt
In the 3rd MonkeyLovers

thanks,
007
AMD Athlon processor
256MB SDRAM
Linux Distro - RedHat 9.0

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Converting filenames to lowercase
« Reply #11 on: 1 June 2003, 21:28 »
hmm try putting this line in front of the `mv' command in the script and post the output here.

echo "$file::$newf"

see, that shouldn't be able to happen because it checks if the files are still the same before it does 'mv'. i might of messed up somewhere (was in a hurry   )
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

Agent007

  • Member
  • **
  • Posts: 120
  • Kudos: 0
Converting filenames to lowercase
« Reply #12 on: 2 June 2003, 11:15 »
Here it is....

 
quote:

/mnt/Setups/linux/window_managers/gkrellm/Acqua.gkrellm.tar.gz::/mnt/Setups/linux/window_managers/gkrellm/acqua.gkrellm.tar.gz mv /mnt/Setups/linux/window_managers/gkrellm/Acqua.gkrellm.tar.gz /mnt/Setups/linux/window_managers/gkrellm/acqua.gkrellm.tar.gz
/mnt/Setups/linux/window_managers/gkrellm/ASDDFASDF_sdakjfkas_aa.zip::/mnt/Setups/linux/window_managers/gkrellm/asddfasdf_sdakjfkas_aa.zip mv /mnt/Setups/linux/window_managers/gkrellm/ASDDFASDF_sdakjfkas_aa.zip /mnt/Setups/linux/window_managers/gkrellm/asddfasdf_sdakjfkas_aa.zip
/mnt/Setups/linux/window_managers/gkrellm/CoplandOS.gkrellm.tar.gz::/mnt/Setups/linux/window_managers/gkrellm/coplandos.gkrellm.tar.gz mv /mnt/Setups/linux/window_managers/gkrellm/CoplandOS.gkrellm.tar.gz /mnt/Setups/linux/window_managers/gkrellm/coplandos.gkrellm.tar.gz
/mnt/Setups/linux/window_managers/gkrellm/theme_MonkeyLovers.tar.gz::/mnt/Setups/linux/window_managers/gkrellm/theme_monkeylovers.tar.gz mv /mnt/Setups/linux/window_managers/gkrellm/theme_MonkeyLovers.tar.gz /mnt/Setups/linux/window_managers/gkrellm/theme_monkeylovers.tar.gz


AMD Athlon processor
256MB SDRAM
Linux Distro - RedHat 9.0

Agent007

  • Member
  • **
  • Posts: 120
  • Kudos: 0
Converting filenames to lowercase
« Reply #13 on: 5 June 2003, 13:28 »
hi!!

Has anyone found a fix for this? or is there an alternative??

thanks
AMD Athlon processor
256MB SDRAM
Linux Distro - RedHat 9.0