Computing.Net > Forums > Unix > rename all files with an extension

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

rename all files with an extension

Reply to Message Icon

Name: roger
Date: August 2, 2002 at 16:19:07 Pacific
Comment:

How do I rename all the files in a particular directory with the file extension .UNC for uncompressed. They are compressed and have a .Z extension but after I uncompress them they don't have an extension. This is on an AIX 4.2 ksh machine.



Sponsored Link
Ads by Google

Response Number 1
Name: Frank
Date: August 4, 2002 at 23:42:10 Pacific
Reply:

Hi Roger,

I hope I understood the question correct.

for i in *.UNC ; do
mv $i $i.Z
done

this will change all *.unc files
to *.unc.Z

I this what you would like to have or do you would like to replace the UNC against Z ?

No RISK no fun
Frank



0

Response Number 2
Name: roger34
Date: August 6, 2002 at 14:13:53 Pacific
Reply:

Thanks Frank that worked great.


0

Response Number 3
Name: Dave
Date: August 9, 2002 at 12:42:29 Pacific
Reply:

How would you go about replacing *.UNC with *.Z?



0

Response Number 4
Name: Frank
Date: August 13, 2002 at 04:13:27 Pacific
Reply:

Hi Dave,

sorry didn't saw your question earlier.

for file in `ls *.i` ; do
new=`echo $file | sed -e "s/.UNC$/.Z/"
if [ ! -f ${new} ]
then
mv ${file} ${new}
else
echo "$new already exist " 1>&2
fi
done


No RISK no fun
. Frank


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: rename all files with an extension

findig files with date extensions www.computing.net/answers/unix/findig-files-with-date-extensions/7900.html

unix command help www.computing.net/answers/unix/unix-command-help/6321.html

Deleting a File with No Extension www.computing.net/answers/unix/deleting-a-file-with-no-extension/7648.html