Re: remove words from mutiple files



On Tue, 30 Dec 2008 05:41:17 -0800, Jesse Dorland wrote for every to
trash:

On Dec 30, 12:36 am, Mysterious Traveler <mysterious_trave...@xxxxxxx>
wrote:
Jesse Dorland wrote:
I have downloaded some 100 astronomical files. All of the files have
words "Mr. Big". Is there a way to remove these words?

If your word processor has a find and replace option, you can have it
find "Mr. Big" and in the replace field try using a space for the word.
In Windows I was able to do this by holding down the alt key and
pressing 255 on the keypad, this makes an invisible character that
takes the place of the words you want to get rid of, but in Linux those
characters can't be made. Maybe someone else can suggest a way, or you
could edit those text files running Windows.

Mysterious Traveler

Well, my situation is bit more complicated. You see, in this folder I
have some 100 .doc files, and about 200 .jpg files. Inside all the doc
files, I have a word "Mr. Big", and then all the files names
(Saturn_Mr.Big.doc), (Venus_Mr.Big.doc), and same goes for .jpgs files.

So I want to remove not only from documents, but from files names too.

That would be a good use for the rename feature if its in Ubuntu.

If not use Aho's example to rename the file during the mv step.

or here's an old example

#!/bin/sh
# renames files
if [ $# -eq 0 ] # if there is input
then
echo $1 "requires dir filenam/n";
exit
fi

for filename in $1 # Not necessary to use basename,
# since "*" won't return any file containing "/".

do n=`echo "$filename" | tr '[A-Z]' '{a-z}'`
# Variable substitution:

n=${n%/} # Removes trailing slash, added above, from filename.
[[ $filename == $n ]] || cp "$filename" "$n"
# Checks if filename already lowercase.
[[ $filename == $n ]] || echo "$filename" " moved to " "$n" >> /tmp/
fmtfile.ans
# Prints changed filenames
done
.



Relevant Pages

  • Re: Changing Uppercase filenames into Lowercase
    ... > I already found MAKEUP.COM which breaks down a filename ... > uses the RENAME command to rename lowercase names and ... > lowercase filename. ... > The filename remains uppercase because DCL uppercases ...
    (comp.os.vms)
  • Re: Renaming files using wildcards
    ... When I strip down the filenames of their ... spaces, the rename works well. ... strip the filename of it's spaces, ... rename command can't find the file name to rename when it ...
    (microsoft.public.windowsxp.general)
  • Re: Cannot delete file with long name
    ... Completely ignores attempts to rename. ... Did find a utility which is able to display the short filename and delete ... Explorer shell to crash. ... I can delete the problem files by deleting the entire folder they are ...
    (microsoft.public.windowsxp.general)
  • Re: media player 10
    ... rename your media library. ... I have XP and all I did was to copy the filename ... If nothing happens soon I'll just switch media players! ...
    (microsoft.public.windowsmedia.player)