|
Next: Me linux gots a virus
|
| Author |
Message |
External

Since: Dec 31, 2008 Posts: 1
|
(Msg. 16) Posted: Wed Dec 31, 2008 2:17 am
Post subject: Re: remove words from mutiple files [Login to view extended thread Info.] Archived from groups: alt>linux (more info?)
|
|
|
On Dec 30, 1:41 pm, Jesse Dorland <jessedorl....RemoveThis@hotmail.com> wrote:
> On Dec 30, 12:36 am, Mysterious Traveler <mysterious_trave....RemoveThis@dot.net>
> 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.
If these .doc's are MS Word files then create a macro to find &
replace then save & close the file & set that to be run whenever a
document is opened. Then you can use dos to do something like
for %%x in *.doc do start %x
I think you can rename a whole batch of files in dos using ren
*big.jpg *.jpg
If it dosnt work you can use something like the for command above &
use set to strip text from %x. Type help set to get the syntax, it's
something like
set y = %x:_Mr Big=% then ren %x %y
ms dos for only looks like it can handle 1 command in the do section
so you will need to write a .bat file to handle anything in the for &
have for execute that batch.
I would take a backup copy of the whole lot before you start & maybe
test the commands etc on a subset just to speed it all up.
Jonathan. |
|
| Back to top |
|
 |  |
External

Since: Sep 26, 2008 Posts: 9
|
(Msg. 17) Posted: Wed Dec 31, 2008 10:08 am
Post subject: Re: remove words from mutiple files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
jb wrote:
> On Dec 30, 1:41 pm, Jesse Dorland <jessedorl....RemoveThis@hotmail.com> wrote:
>> On Dec 30, 12:36 am, Mysterious Traveler
>> <mysterious_trave....RemoveThis@dot.net> 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.
>
> If these .doc's are MS Word files then create a macro to find &
> replace then save & close the file & set that to be run whenever a
> document is opened. Then you can use dos to do something like
> for %%x in *.doc do start %x
> I think you can rename a whole batch of files in dos using ren
> *big.jpg *.jpg
> If it dosnt work you can use something like the for command above &
> use set to strip text from %x. Type help set to get the syntax, it's
> something like
> set y = %x:_Mr Big=% then ren %x %y
> ms dos for only looks like it can handle 1 command in the do section
> so you will need to write a .bat file to handle anything in the for &
> have for execute that batch.
> I would take a backup copy of the whole lot before you start & maybe
> test the commands etc on a subset just to speed it all up.
>
> Jonathan.
Please note; Since this is a Linux newgroup, the Windows/DOS solution
probably isn't what they were needing.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle! |
|
| Back to top |
|
 |  |
External

Since: Nov 12, 2005 Posts: 26
|
(Msg. 18) Posted: Wed Dec 31, 2008 9:14 pm
Post subject: Re: remove words from mutiple files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Tue, 30 Dec 2008 19:12:30 +0000, Chill Out wrote:
> On Tue, 30 Dec 2008 17:04:26 +0000, Stefan Patric wrote for every to
> trash:
>
>> On Tue, 30 Dec 2008 15:13:33 +0100, J.O. Aho wrote:
>>
>>> Jesse Dorland wrote:
>>>
>>>> Do you know if it will remove the words from inside documents, or
>>>> files names as well?
>>>
>>> sed will remove inside the file, if you want to replace the string in
>>> a filename, you need to make a small shell script that reads the whole
>>> directory and uses mv and sed together to rename the files that has
>>> the offending string it's name.
>>>
>>> --- remove string from filename ---
>>> #!/bin/sh
>>> for file in *
>>> do
>>> change_name_to=`echo $file | sed 's/Mr\. Big\//'` mv "./$file"
>>> "./$change_name_to"
>>> done
>>> --- eof ---
>>
>> Easier would be to do two separate operations using wildcards to affect
>> all the files: First, sed to find and remove the text; then, rename
>> (instead of mv) to rename the files. Very fast. Very simple. No
>> scripting required.
>>
>> Stef
>
> No mv is more efficient.
How so? More efficient in the script or just more efficient overall?
Faster? What?
Always looking for "better" ways to do the same thing.
Stef |
|
| Back to top |
|
 |  |
External

Since: Jan 11, 2007 Posts: 4
|
(Msg. 19) Posted: Thu Jan 01, 2009 10:17 pm
Post subject: Re: remove words from mutiple files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Wed, 31 Dec 2008 21:14:05 +0000, Stefan Patric wrote for every to
trash:
> On Tue, 30 Dec 2008 19:12:30 +0000, Chill Out wrote:
>
>> On Tue, 30 Dec 2008 17:04:26 +0000, Stefan Patric wrote for every to
>> trash:
>>
>>> On Tue, 30 Dec 2008 15:13:33 +0100, J.O. Aho wrote:
>>>
>>>> Jesse Dorland wrote:
>>>>
>>>>> Do you know if it will remove the words from inside documents, or
>>>>> files names as well?
>>>>
>>>> sed will remove inside the file, if you want to replace the string in
>>>> a filename, you need to make a small shell script that reads the
>>>> whole directory and uses mv and sed together to rename the files that
>>>> has the offending string it's name.
>>>>
>>>> --- remove string from filename ---
>>>> #!/bin/sh
>>>> for file in *
>>>> do
>>>> change_name_to=`echo $file | sed 's/Mr\. Big\//'` mv "./$file"
>>>> "./$change_name_to"
>>>> done
>>>> --- eof ---
>>>
>>> Easier would be to do two separate operations using wildcards to
>>> affect all the files: First, sed to find and remove the text; then,
>>> rename (instead of mv) to rename the files. Very fast. Very simple.
>>> No scripting required.
>>>
>>> Stef
>>
>> No mv is more efficient.
>
> How so? More efficient in the script or just more efficient overall?
> Faster? What?
>
> Always looking for "better" ways to do the same thing.
>
> Stef
I took what you meant as 2 separate operations.
Honestly, I take back what I wrote.
Most efficient is the method that gets it right the first time and takes
the least of your time. Except for gaining knowledge why waste 3hrs to
write the perfect script when 2 commands or 2 quick scripts in 1hr will
get the job done, right? |
|
| Back to top |
|
 |  |
| Related Topics: | remove drm from wmv files - Hi all, mplayer sometimes doesn't play wmv files, and I suspect its because they have drm. The screen becomes green and garbled. Does anyone know of a way to remove drm from wmv files? It would have to work on linux. iksrazal
Command line to remove duplicate files? - I have a Fedora 6 system and want to remove some duplicate files. I have about 1,500 jpg images on my XP machine on the LAN and setup the directory containing the photos as a share, then mounted it in Linux with cifs, so now I can use Linux tools on..
How to remove files created by 'mknod'? (kernel version 2... - Hi all, I cannot delete files created by 'mknod'. I used a subdir in my home directory (NFS mounted) as a staging area for Linux filesystem contents that were used as inputs to mkfs.* utilities. Now I am done and want to get rid of all the files, for...
IS THE BIBLE GOD'S WORDS!!! - IS THE BIBLE GOD'S WORDS!!! In RSV Bible see the sixth paragraph of the preface (for example only you can complete reading and discovering by yourself): YET THE KING JAMES VERSION HAS GRAVE DEFECTS. By the middle of the nineteenth century, the..
How to count words in a postscript file? - Is there a command to do it? I tried "wc -w file.ps". It did not work. Thanks a lot. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|