1833762 Members
2456 Online
110063 Solutions
New Discussion

multiple renames

 
Greta Blamire
Frequent Advisor

multiple renames

I have 72 patches to put in a depot and install. But first I need to take the .html extension off the file name. Would someone give me a command to change them without having to do the mv command 72 times?
If you can't face the facts, change them!
9 REPLIES 9
Craig Rants
Honored Contributor

Re: multiple renames

If I read you question right...

ls *.html > filename.out
sed 's/.html//g' filename.out > filename1.out
for i in `cat filename1.out`
do
mv $i.html $i
done


That should work for you.

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
harry d brown jr
Honored Contributor

Re: multiple renames

cd

find . -type f -name "*.html" | sed "s/\.html$//" | xargs -i mv {}.html {}

live free or die
harry
Live Free or Die
James R. Ferguson
Acclaimed Contributor

Re: multiple renames

Hi Greta:

From your description, I believe that what you really want/need to do is to unshar the patches and collect them into a single depot for installation. Assuming that this is true, and assuming that the patches are titled "PHxx.html", do this:

PDIR=/tmp/patch_depot

cd /tmp
for X in PH*.html
do
sh ${X}
done

mkdir ${PDIR}
for X in PH*.depot
do
swcopy -s ${PWD}/${X} \* @ ${PDIR}
done

...now you can 'swinstall' with one reboot (if necessary) using 'tmp/patch_depot' as the source depot

Regards!

...JRF...
harry d brown jr
Honored Contributor

Re: multiple renames

Greta, next time try using the customized patch manager, which will "bundle" your individually selected patches into a single "bundle" to be downloaded and installed.


live free or die
harry
Live Free or Die
A. Clay Stephenson
Acclaimed Contributor

Re: multiple renames

Hi Greta:

You really don't need to because sh PHNE_12345.html works just as well as sh PHNE_12345 and does not append the .html to the .depot and .text files in either case. In fact, you can download all the files into a directory and simply sh PH* and that will unshare the files.
If it ain't broke, I can fix that.
Robin Wakefield
Honored Contributor

Re: multiple renames

Hi Greta,

Assuming you still want to do this, here's a way without using sed:

for file in *.html ; do
echo mv $file ${file%.html}
done

Rgds, Robin.
Robin Wakefield
Honored Contributor

Re: multiple renames

Hi Greta,

Please scrub the "echo" from my previous reply to actually run it, this was to preview the commands.

Rgds, Robin.
Krishna Prasad
Trusted Contributor

Re: multiple renames

It looks like you got lots of help for the rename.

I just wanted to give you a heads up if you don't know about the

If you downloaded from the web which I assume you did via the .html extensions. I usally get html code at the begining that needs to be removed before I run the sh command.
Positive Results requires Positive Thinking
Joseph C. Denman
Honored Contributor

Re: multiple renames

a million ways to skin that darn cat!!!

for x in `ls *.html`
do
file=`echo $x | cut -f1 -d"."`
mv $x $file
done



...jcd...
If I had only read the instructions first??