| Author |
using find to rename from 'name .ext' to 'name.ext'
|
|
| Chris Lott 2006-12-14, 7:29 pm |
| I have many directories full of files that have a space before the
extension:
file .txt
file2 .txt
file3 .txt
I'm trying to use find and sed to rename them quckly to:
file.txt
file2.txt
file3.txt
Gleaned from the web I came up with osmething like this, but the names
are not fixed:
find . -name '* .mp3' -exec mv {} {} \; | sed 's/[:space:].txt$/.txt/'
is this close?
| |
| Frank Terbeck 2006-12-14, 7:29 pm |
| Chris Lott <Chris.Lott@gmail.com>:
[...]
> file .txt
[...]
> I'm trying to use find and sed to rename them quckly to:
> file.txt
[...]
How about :
[snip]
find . -name "* .txt" -exec \
sh -c 'file="{}"; mv "${file}" "${file% .txt}.txt"' \;
[snap]
Regards, Frank
--
There are no threads in alt.binaries.pictures.erotica,
so there's no gain in using a threaded news reader.
-- unknown source
| |
| Stephane CHAZELAS 2006-12-15, 7:33 am |
| 2006-12-15, 00:39(+01), Frank Terbeck:
> Chris Lott <Chris.Lott@gmail.com>:
> [...]
> [...]
> [...]
>
> How about :
>
> [snip]
> find . -name "* .txt" -exec \
> sh -c 'file="{}"; mv "${file}" "${file% .txt}.txt"' \;
> [snap]
find . -name "* .txt" -exec sh -c '
file=$1; exec mv "${file}" "${file% .txt}.txt"' {} {} \;
zmv '(**/)(*) (.txt)' '$1$2$3'
--
Stéphane
|
|
|
|