LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   renaming extensions (https://www.linuxquestions.org/questions/linux-newbie-8/renaming-extensions-446632/)

christina_rules 05-20-2006 03:12 AM

renaming extensions
 
i am very new in linux and hoping that i am able to get help here...can i know when we can't rename extensions by simply typing mv *.cpp *.c?

Zmyrgel 05-20-2006 03:17 AM

Not sure but I think you need to be more specific with that renaming. like "mv baa.cpp baa.c". I'm myself not that familiar with linux. Also, check file permissions.

spooon 05-20-2006 04:38 AM

Quote:

Originally Posted by christina_rules
i am very new in linux and hoping that i am able to get help here...can i know when we can't rename extensions by simply typing mv *.cpp *.c?

No. "mv" moves a bunch of files to one destination, so if you tried to do that it would try to move all the *.cpp and all but the last of the *.c files into the last .c file, which is not what you want (and does not work). Try something like
Code:

rename .cpp .c *.cpp

christina_rules 05-23-2006 03:11 AM

thank you for solving the problem.
but if you don't mind can you explain how the code works? like why there are 3 arguments?

Quote:

but the last of the *.c files into the last .c file, which is not what you want (and does not work).
and what does this mean?

spooon 05-23-2006 03:29 AM

Quote:

Originally Posted by christina_rules
but if you don't mind can you explain how the code works? like why there are 3 arguments?

read "man rename"

Quote:

Originally Posted by christina_rules
and what does this mean?

So "mv" works like this: suppose you do "mv A B C D E F", it tries to move the 5 things (A B C D E) into the directory F. When you do "mv *.cpp *.c", the shell expands the wildcards, so it becomes something like "mv A.cpp B.cpp C.cpp D.c E.c F.c" for example. Then it tries to move the 5 things (A.cpp B.cpp C.cpp D.c E.c) into the directory "F.c". Which is not what you wanted.

christina_rules 05-23-2006 08:58 AM

thank you so much...i understand it clearly now..i appreciate it :)

christina_rules 05-23-2006 09:04 AM

thank you so much...i understand it clearly now..i appreciate it :)


All times are GMT -5. The time now is 02:04 PM.