space problem

I have a listing of *.jpg files from a digital camera and some of them
(not all) have a space in the file name.
I am having problem renaming the files with the space in them .

my first thought was sed s/ /_/g $file but sed doesn't work with 'ls'

how else to write a script that renames a list of jpgs with [[:space:]]
in it ?


thanx

Grant
grant [ Sa, 27 Oktober 2007 21:16 ] [ ID #1855694 ]

Re: space problem

Grant wrote:
> I have a listing of *.jpg files from a digital camera and some of them
> (not all) have a space in the file name.
> I am having problem renaming the files with the space in them .
>
> my first thought was sed s/ /_/g $file but sed doesn't work with 'ls'
>
> how else to write a script that renames a list of jpgs with [[:space:]]
> in it ?

for i in *\ *.jpg; do echo mv -v $i ${i// /_}; done

Without collision test. Check output and then remove "echo".

--
Best | "Richtig ist sicher, dass die katholische Kirche die groesste
regards | transnationale Schwulenorganisation ist."
Cyrus | -- Priester Hermann Kügler im Interview mit Spiegel Online
Cyrus Kriticos [ Sa, 27 Oktober 2007 08:40 ] [ ID #1855695 ]

Re: space problem

Grant wrote:
> I have a listing of *.jpg files from a digital camera and some of them
> (not all) have a space in the file name.
> I am having problem renaming the files with the space in them .
>
> my first thought was sed s/ /_/g $file but sed doesn't work with 'ls'
>
> how else to write a script that renames a list of jpgs with [[:space:]]
> in it ?

for i in *\ *.txt; do echo mv "$i" "${i// /_}"; done

Without collision test. Check output and then remove "echo".

--
Best | "Richtig ist sicher, dass die katholische Kirche die groesste
regards | transnationale Schwulenorganisation ist."
Cyrus | -- Priester Hermann Kügler im Interview mit Spiegel Online
Cyrus Kriticos [ Sa, 27 Oktober 2007 08:47 ] [ ID #1855696 ]

Re: space problem

Grant wrote:
> I have a listing of *.jpg files from a digital camera and some of them
> (not all) have a space in the file name.
> I am having problem renaming the files with the space in them .
>
> my first thought was sed s/ /_/g $file but sed doesn't work with 'ls'
>
> how else to write a script that renames a list of jpgs with [[:space:]]
> in it ?

for i in *\ *.jpg; do echo mv "$i" "${i// /_}"; done

Without collision test. Check output and then remove "echo".

--
Best | "Richtig ist sicher, dass die katholische Kirche die groesste
regards | transnationale Schwulenorganisation ist."
Cyrus | -- Priester Hermann Kügler im Interview mit Spiegel Online
Cyrus Kriticos [ Sa, 27 Oktober 2007 08:50 ] [ ID #1855697 ]

Re: space problem

Cyrus Kriticos a écrit :
>
> Grant wrote:
>> I have a listing of *.jpg files from a digital camera and some of them
>> (not all) have a space in the file name.
>> I am having problem renaming the files with the space in them .
>>
>> my first thought was sed s/ /_/g $file but sed doesn't work with 'ls'
>>
>> how else to write a script that renames a list of jpgs with
>> [[:space:]] in it ?
>
> for i in *\ *.jpg; do echo mv "$i" "${i// /_}"; done
>
> Without collision test. Check output and then remove "echo".
>

For this I use :

rename 's/ /_/g' *.jpg
sputnick [ Mi, 28 November 2007 00:02 ] [ ID #1879570 ]
Linux » comp.unix.shell » space problem

Vorheriges Thema: shell script source getting actual path problem
Nächstes Thema: formatting question...