| Author |
changing all filenames to uppercase!
|
|
| student 2002-08-25, 11:29 am |
| hello
anybody body knows a command to change all the files in a directory
from lowercase to uppercase. I don't want to type mv file FILE for a
few hundred times :P
thank you!
| |
| David Dorward 2002-08-25, 11:29 am |
| student might have typed:
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
for x in *; do mv "$x" "`echo $x | sed
"y/ *[abcdefghijklmnopqrstuvwxyz]*
/ *[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*
/"`"; done
--
David Dorward http://david.us-lot.org/
Thinking about emailing me? Only do so if it isn't apropriate for this
newsgroup. If it should have been in the group it will probably be ignored.
| |
| Michael Heiming 2002-08-25, 11:29 am |
| David Dorward
(<1030291095.17181.0.nnrp-08.9e98eae2@news.demon.co.uk> ):
> student might have typed:
>
>> hello
>> anybody body knows a command to change all the files in a
>> directory
>> from lowercase to uppercase. I don't want to type mv file FILE
>> for a
>> few hundred times :P
>> thank you!
>
> for x in *; do mv "$x" "`echo $x | sed
>
"y/ *[abcdefghijklmnopqrstuvwxyz]*
/ *[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*
/"`";
> done
>
Or use 'tr':
$ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
Michael Heiming
--
Remove the +SIGNS case mail bounces.
| |
| student 2002-08-25, 11:29 am |
| In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
<michael+USENET@heiming.de> wrote:
> David Dorward
> (<1030291095.17181.0.nnrp-08.9e98eae2@news.demon.co.uk> ):
>
>> student might have typed:
>>
>>> hello
>>> anybody body knows a command to change all the files in a
>>> directory
>>> from lowercase to uppercase. I don't want to type mv file FILE
>>> for a
>>> few hundred times :P
>>> thank you!
>>
>> for x in *; do mv "$x" "`echo $x | sed
>>
> "y/ *[abcdefghijklmnopqrstuvwxyz]*
/ *[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*
/"`";
>> done
>>
>>
> Or use 'tr':
>
> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>
> Michael Heiming
> --
> Remove the +SIGNS case mail bounces.
Thank you for your reply
but could you kindly tell me where I should put the above commands?
simply type them in bash?
thank you!
| |
| Michael Heiming 2002-08-25, 11:29 am |
| student (<20020826.002510.7684930.4476@student.com> ):
> In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
> <michael+USENET@heiming.de> wrote:
>> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>
> Thank you for your reply
> but could you kindly tell me where I should put the above
> commands? simply type them in bash?
Where would you have typed 'mv ...' a few hundred times?
The '$' just represents PS1, you DON'T need to type it.
Michael Heiming
--
Remove the +SIGNS case mail bounces.
| |
| student 2002-08-25, 12:29 pm |
| In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
<michael+USENET@heiming.de> wrote:
> David Dorward
> (<1030291095.17181.0.nnrp-08.9e98eae2@news.demon.co.uk> ):
>
>> student might have typed:
>>
>>> hello
>>> anybody body knows a command to change all the files in a
>>> directory
>>> from lowercase to uppercase. I don't want to type mv file FILE
>>> for a
>>> few hundred times :P
>>> thank you!
>>
>> for x in *; do mv "$x" "`echo $x | sed
>>
> "y/ *[abcdefghijklmnopqrstuvwxyz]*
/ *[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*
/"`";
>> done
>>
>>
> Or use 'tr':
>
> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>
> Michael Heiming
> --
> Remove the +SIGNS case mail bounces.
Thank you for your reply
but could you kindly tell me where I should put the above commands?
simply type them in bash?
thank you!
| |
| Michael Heiming 2002-08-25, 12:29 pm |
| student (<20020826.002510.7684930.4476@student.com> ):
> In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
> <michael+USENET@heiming.de> wrote:
>> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>
> Thank you for your reply
> but could you kindly tell me where I should put the above
> commands? simply type them in bash?
Where would you have typed 'mv ...' a few hundred times?
The '$' just represents PS1, you DON'T need to type it.
Michael Heiming
--
Remove the +SIGNS case mail bounces.
| |
|
| student wrote:
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
>
#!/bin/sh
directory=$(pwd)
listing=$(ls $directory)
for i in $listing; do
uppercase=$(echo $i|awk '{print toupper($0)}')
mv $i $uppercase
done
Make that a script in your ~/bin directory, chmod it to be executable
and cd to the directory you want and run it.
DanH
--
UNIX - Not just for Vestal Virgins anymore
Linux - Choice of a GNU generation
| |
|
| student wrote:
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
>
#!/bin/sh
directory=$(pwd)
listing=$(ls $directory)
for i in $listing; do
uppercase=$(echo $i|awk '{print toupper($0)}')
mv $i $uppercase
done
Make that a script in your ~/bin directory, chmod it to be executable
and cd to the directory you want and run it.
DanH
--
UNIX - Not just for Vestal Virgins anymore
Linux - Choice of a GNU generation
| |
| Clive Dove 2002-08-25, 4:29 pm |
| student wrote:
> hello
> anybody body knows a command to change all the files in a
> directory
> from lowercase to uppercase. I don't want to type mv file FILE
> for a
> few hundred times :P
> thank you!
Please satisfy my curiosity.
Why would you want to do such a thing?
Linux filenames are case sensitive
foo, Foo and FOO are all different names.
You have been told by others how to do it but careless use of the
technique could result in irreversable chaos in your system.
Or are we simply doing your homework for you?
If so, you had better put a caveat as a footnote in your paper before
you hand it in so that your teacher will know that you are astute to
the risks.
| |
| Bill Unruh 2002-08-25, 4:29 pm |
| Clive Dove <chdove@rogers.com> writes:
]student wrote:
]> hello
]> anybody body knows a command to change all the files in a
]> directory
]> from lowercase to uppercase. I don't want to type mv file FILE
]> for a
]> few hundred times :P
]> thank you!
for i in *
do
mv $i `echo $i|tr 'a-z' 'A-Z'`
done
| |
| Joachim Feise 2002-08-25, 4:29 pm |
| Clive Dove wrote:
> student wrote:
>
>
>>hello
>> anybody body knows a command to change all the files in a
>> directory
>>from lowercase to uppercase. I don't want to type mv file FILE
>>for a
>>few hundred times :P
>> thank you!
>
>
>
> Please satisfy my curiosity.
>
> Why would you want to do such a thing?
>
> Linux filenames are case sensitive
>
> foo, Foo and FOO are all different names.
One thing I can think of is moving a website from Windoze to a *nix box.
For Windoze, foo, Foo and FOO are the same.
But in such a case, you also may have to check the links to make sure
that they have the correct case as well.
-Joe
| |
| Clive Dove 2002-08-25, 5:29 pm |
| student wrote:
> hello
> anybody body knows a command to change all the files in a
> directory
> from lowercase to uppercase. I don't want to type mv file FILE
> for a
> few hundred times :P
> thank you!
Please satisfy my curiosity.
Why would you want to do such a thing?
Linux filenames are case sensitive
foo, Foo and FOO are all different names.
You have been told by others how to do it but careless use of the
technique could result in irreversable chaos in your system.
Or are we simply doing your homework for you?
If so, you had better put a caveat as a footnote in your paper before
you hand it in so that your teacher will know that you are astute to
the risks.
| |
| Bill Unruh 2002-08-25, 5:29 pm |
| Clive Dove <chdove@rogers.com> writes:
]student wrote:
]> hello
]> anybody body knows a command to change all the files in a
]> directory
]> from lowercase to uppercase. I don't want to type mv file FILE
]> for a
]> few hundred times :P
]> thank you!
for i in *
do
mv $i `echo $i|tr 'a-z' 'A-Z'`
done
| |
| Joachim Feise 2002-08-25, 5:29 pm |
| Clive Dove wrote:
> student wrote:
>
>
>>hello
>> anybody body knows a command to change all the files in a
>> directory
>>from lowercase to uppercase. I don't want to type mv file FILE
>>for a
>>few hundred times :P
>> thank you!
>
>
>
> Please satisfy my curiosity.
>
> Why would you want to do such a thing?
>
> Linux filenames are case sensitive
>
> foo, Foo and FOO are all different names.
One thing I can think of is moving a website from Windoze to a *nix box.
For Windoze, foo, Foo and FOO are the same.
But in such a case, you also may have to check the links to make sure
that they have the correct case as well.
-Joe
| |
| George Peter Staplin 2002-08-25, 6:29 pm |
|
"student" <student@student.com> wrote in message
news:20020825.233816.680466996.4476@student.com...
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
This tclsh script should do:
#!/bin/tclsh
foreach f $::argv {
if {[file isdirectory $f]} {
#skip directories
continue
}
set newName [string toupper $f]
puts "renaming $f to $newName"
file rename $f $newName
}
Save that in a file, and chmod +x it. Then use it like so: filetoupper.tcl
* If you just want to convert files with a txt extension then use:
filetoupper.tcl *.txt
George
| |
| George Peter Staplin 2002-08-25, 7:29 pm |
|
"student" <student@student.com> wrote in message
news:20020825.233816.680466996.4476@student.com...
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
This tclsh script should do:
#!/bin/tclsh
foreach f $::argv {
if {[file isdirectory $f]} {
#skip directories
continue
}
set newName [string toupper $f]
puts "renaming $f to $newName"
file rename $f $newName
}
Save that in a file, and chmod +x it. Then use it like so: filetoupper.tcl
* If you just want to convert files with a txt extension then use:
filetoupper.tcl *.txt
George
| |
| Wannabe h4x0r 2002-08-27, 8:42 pm |
| In article <i71bka.o8l.ln@charon.heiming.de>, Michael Heiming wrote:
> student (<20020826.002510.7684930.4476@student.com> ):
>
>> In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
>> <michael+USENET@heiming.de> wrote:
>
>>> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>
>>
>> Thank you for your reply
>> but could you kindly tell me where I should put the above
>> commands? simply type them in bash?
>
> Where would you have typed 'mv ...' a few hundred times?
> The '$' just represents PS1, you DON'T need to type it.
>
> Michael Heiming
> --
> Remove the +SIGNS case mail bounces.
Dude, go over to http://www.linuxcommand.org
It'll help you out alot. It'll save you alot of confusion.
NiCad
| |
| Wannabe h4x0r 2002-08-27, 9:29 pm |
| In article <i71bka.o8l.ln@charon.heiming.de>, Michael Heiming wrote:
> student (<20020826.002510.7684930.4476@student.com> ):
>
>> In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
>> <michael+USENET@heiming.de> wrote:
>
>>> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>
>>
>> Thank you for your reply
>> but could you kindly tell me where I should put the above
>> commands? simply type them in bash?
>
> Where would you have typed 'mv ...' a few hundred times?
> The '$' just represents PS1, you DON'T need to type it.
>
> Michael Heiming
> --
> Remove the +SIGNS case mail bounces.
Dude, go over to http://www.linuxcommand.org
It'll help you out alot. It'll save you alot of confusion.
NiCad
| |
|
| Wannabe h4x0r wrote:
> In article <i71bka.o8l.ln@charon.heiming.de>, Michael Heiming wrote:
>> student (<20020826.002510.7684930.4476@student.com> ):
>>
>>> In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
>>> <michael+USENET@heiming.de> wrote:
>>
>>>> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>>
>>>
>>> Thank you for your reply
>>> but could you kindly tell me where I should put the above
>>> commands? simply type them in bash?
>>
>> Where would you have typed 'mv ...' a few hundred times?
>> The '$' just represents PS1, you DON'T need to type it.
>>
>> Michael Heiming
>> --
>> Remove the +SIGNS case mail bounces.
>
> Dude, go over to http://www.linuxcommand.org
>
> It'll help you out alot. It'll save you alot of confusion.
>
> NiCad
Excellent, Dude! What a worthy url! Seriously, thanks a lot. That's a
really useful site.
Cheers,
Malke
--
Elephant Boy Computers
www.elephantboycomputers.com
"Don't Panic!"
remove 3's to reply
| |
|
| Wannabe h4x0r wrote:
> In article <i71bka.o8l.ln@charon.heiming.de>, Michael Heiming wrote:
>> student (<20020826.002510.7684930.4476@student.com> ):
>>
>>> In article <8nvaka.2vk.ln@charon.heiming.de>, "Michael Heiming"
>>> <michael+USENET@heiming.de> wrote:
>>
>>>> $ for i in * ; do mv $i `echo $i | tr '[a-z]' '[A-Z]'` ; done
>>
>>>
>>> Thank you for your reply
>>> but could you kindly tell me where I should put the above
>>> commands? simply type them in bash?
>>
>> Where would you have typed 'mv ...' a few hundred times?
>> The '$' just represents PS1, you DON'T need to type it.
>>
>> Michael Heiming
>> --
>> Remove the +SIGNS case mail bounces.
>
> Dude, go over to http://www.linuxcommand.org
>
> It'll help you out alot. It'll save you alot of confusion.
>
> NiCad
Excellent, Dude! What a worthy url! Seriously, thanks a lot. That's a
really useful site.
Cheers,
Malke
--
Elephant Boy Computers
www.elephantboycomputers.com
"Don't Panic!"
remove 3's to reply
| |
| Bruce Burhans 2002-08-28, 9:29 am |
|
"student" <student@student.com> wrote in message
news:20020825.233816.680466996.4476@student.com...
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
$ ls | tr a-z A-Z
Bruce<+>
| |
| Bruce Burhans 2002-08-28, 10:30 am |
|
"student" <student@student.com> wrote in message
news:20020825.233816.680466996.4476@student.com...
> hello
> anybody body knows a command to change all the files in a directory
> from lowercase to uppercase. I don't want to type mv file FILE for a
> few hundred times :P
> thank you!
$ ls | tr a-z A-Z
Bruce<+>
|
|
|
|