# change filenames to Proper case

**URL:** <https://community.unix.com/t/change-filenames-to-proper-case/175954>\
**Category:** Shell Programming and Scripting\
**Created:** [September 26, 2007, 10:19am UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954 "2007-09-26T10:19:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![prvnrk](https://community.unix.com/letter_avatar/prvnrk/32/6_449c533f586939b6e5f246632a46421f.png) [@prvnrk](https://community.unix.com/u/prvnrk)\
**Post date:** [September 26, 2007, 10:19am UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/1 "2007-09-26T10:19:57Z")

</div>

Hi,

I have files with all its characters in lower cases. I need to change them to "proper case" (starting char to be come Upper case). How can I? Pls suggest.

for e.g. xyz.txt should become Xyz.txt

TIA  
Prvn

---

<div class="post-metadata">

**Author:** ![radoulov](https://community.unix.com/user_avatar/community.unix.com/radoulov/32/489_2.png) [@radoulov](https://community.unix.com/u/radoulov)\
**Post date:** [September 26, 2007, 10:36am UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/2 "2007-09-26T10:36:27Z")

</div>

With zsh:

```nohighlight
zsh 4.3.4% touch xyz.txt abc.txt
zsh 4.3.4% autoload -U zmv
zsh 4.3.4% zmv '(*).(*)' '${(C)1}.$2' 
zsh 4.3.4% ls
Abc.txt Xyz.txt

```

---

<div class="post-metadata">

**Author:** ![ghostdog74](https://community.unix.com/letter_avatar/ghostdog74/32/6_449c533f586939b6e5f246632a46421f.png) [@ghostdog74](https://community.unix.com/u/ghostdog74)\
**Post date:** [September 26, 2007, 11:51am UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/3 "2007-09-26T11:51:25Z")

</div>

if you can use Python:

```nohighlight
# echo "abc.txt" | python -c "print raw_input().capitalize()"
Abc.txt

```

---

<div class="post-metadata">

**Author:** ![prvnrk](https://community.unix.com/letter_avatar/prvnrk/32/6_449c533f586939b6e5f246632a46421f.png) [@prvnrk](https://community.unix.com/u/prvnrk)\
**Post date:** [September 26, 2007, 12:25pm UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/4 "2007-09-26T12:25:27Z")

</div>

Thanks ghostdog74 & radoulov.

I'm allowed to use bash/ksh/sh only.

Prvn

---

<div class="post-metadata">

**Author:** ![ghostdog74](https://community.unix.com/letter_avatar/ghostdog74/32/6_449c533f586939b6e5f246632a46421f.png) [@ghostdog74](https://community.unix.com/u/ghostdog74)\
**Post date:** [September 26, 2007, 12:55pm UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/5 "2007-09-26T12:55:52Z")

</div>

```nohighlight
echo "abc.txt" | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}'

```

---

<div class="post-metadata">

**Author:** ![prvnrk](https://community.unix.com/letter_avatar/prvnrk/32/6_449c533f586939b6e5f246632a46421f.png) [@prvnrk](https://community.unix.com/u/prvnrk)\
**Post date:** [September 26, 2007, 1:07pm UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/6 "2007-09-26T13:07:02Z")

</div>

Hi Ghostdog,

I am getting abc.txt as it as but Abc.txt was expected.

#echo "abc.txt" | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}'

abc.txt  
#

Thanks

---

<div class="post-metadata">

**Author:** ![prvnrk](https://community.unix.com/letter_avatar/prvnrk/32/6_449c533f586939b6e5f246632a46421f.png) [@prvnrk](https://community.unix.com/u/prvnrk)\
**Post date:** [September 26, 2007, 1:51pm UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/7 "2007-09-26T13:51:10Z")

</div>

Hi Ghostdog,

I installed gawk 3.1.5 and your solution worked great.

Thanks much

Prvn

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [September 26, 2007, 2:43pm UTC](https://community.unix.com/t/change-filenames-to-proper-case/175954/8 "2007-09-26T14:43:12Z")

</div>

In straight shell

```nohighlight
filename=abc.txt
typeset -u first=$(expr substr $filename 1 1)
mv $filename $first$(expr substr $filename 2 ${#filename})

```
