Re: Removing single quote from filenames (recursively)
carlos_at_linux.it
Date: 08/17/04
- Next message: Jan Foucek: "awk @ hpux makes unwanted numeric conversion"
- Previous message: Chris F.A. Johnson: "Re: set -s"
- Next in thread: foo: "Re: Removing single quote from filenames (recursively)"
- Reply: foo: "Re: Removing single quote from filenames (recursively)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 17 Aug 2004 16:33:59 +0200 (CEST)
Ben <bbkennedy00@yahoo.com> wrote:
> Hello all,
> I've got a bunch of files that have a single quote in them, and I'd
> like to rename them so that the quote is removed.
Supposing that you want to rename all files in a directory:
cd target_directory
for i in *
do
j=$(echo "$i" | tr -d "'")
mv "$i" "$j"
done
If some of the filenames do not contain quotes 'mv' will complain, but
it won't hurt. Furthermore, you may want to account for special cases,
such as a file which name is all quotes, so you may need to adapt the
above code snippet a bit.
If the files to be renamed are not in the same directory you may need
to use 'find' as opposed to '*' in the for-loop above, but you get the
idea. Using 'sed' is very portable and you do not need to install other
(large and bloated) stuff that you may not have on your system, like
'zsh' or anything.
Carlo
-- Protect Innovation Against Software Patents: http://swpat.ffii.org
- Next message: Jan Foucek: "awk @ hpux makes unwanted numeric conversion"
- Previous message: Chris F.A. Johnson: "Re: set -s"
- Next in thread: foo: "Re: Removing single quote from filenames (recursively)"
- Reply: foo: "Re: Removing single quote from filenames (recursively)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|