Getting error by renaming all the files in a folder

Hi All,

I have a folder name as postscript folder and it contains the following postscript files.

package1.ps
package2.ps
package3.ps

when i am renaming all the ps files to xps files by using the following command

mv /postscript/.ps /postscript/.xps

Then i am getting the following error.

mv: /postscript/*.xps not found

Check with the path, you have mentioned /postscript and probably your folder is not in root directory.

yes my folder is present in the root directory...

I already checked that one. then also i am getting the error........

please help me........

The problem is a general misconception about how the commandline is evaluated. an asterisk ("*") is evaluated to a list of files by the shell! So, if there are the three files you mentioned in the directory what the mv command will get is (i skip the directories as they are not relevant):

mv package1.ps package2.ps package3.ps *.xps

As ".xps" cannot be evaluated (by the time you issue the command there are no files named ".xps") the error occurs. And even if it wouldn't occur (suppose you would have some *.xps files in the directory) the result would probably not be what you wanted to achieve. What you really want to do is:

mv package1.ps package1.xps
mv package2.ps package2.xps
...

For occasions like this use a little loop:

cd /postscript
for file in $(ls *.ps) ; do         # this sets the "file" variable to one filename after the other
     mv ${file%.*} ${file%.*}.xps   # ${file%.*} cuts off the point and everything that follows from $file
done

I hope this helps.

bakunin

hai sunita
this is suvendu here
for renaming this u have e easy option like this:
find . -name "*.ps"|sed 's/.ps/.xps/g'
do like this u will find the result
thank u