How to rename a directory in C

0 votes
I searched online to find that how to change the directory name? But I found nothing. All I found was rename() that was changing filenames. I want to change a directory name. Linux uses mv command for renaming a directory but if the directory contains large files then moving will take time more right? I want to do this in C.
Apr 26, 2022 in Linux Administration by Edureka
• 13,690 points
901 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

stdio.h header file defines the rename() function in C int rename(const char * oldname, const char * newname); rename() method in C int rename(const char * oldname, const char * newname); rename() function in C int rename(const char * oldname, const char * newname); rename() It changes the name of a file or folder from oldname to newname. Because the rename and move operations are the same, you can use this function to move a file.

int rename(const char * oldname, const char * newname);

It takes two parameters, oldname and newname, both of which are pointers to constant characters that define the file's old and new names.

If the file was properly renamed, it returns zero; otherwise, it returns a non-zero integer. If a file with the same name already exists, the rename action replaces the existing file.

answered Apr 27, 2022 by Edureka
• 13,690 points

edited Mar 5

Related Questions In Linux Administration

0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Feb 1, 2019 in Linux Administration by Omkar
• 69,220 points
1,406 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 21, 2019 in Linux Administration by DareDev
• 6,890 points
1,075 views
0 votes
2 answers

How do I use a shell script to SSH in to a remote machine to execute commands?

Sorry in advance for any formatting. Check out ...READ MORE

answered Feb 7, 2021 in Linux Administration by anonymous
17,526 views
0 votes
1 answer
0 votes
1 answer

How to check permissions of a folder in the Linux system?

Hi@akhtar, You can use ls command to check ...READ MORE

answered Aug 13, 2020 in Linux Administration by MD
• 95,460 points
10,180 views
0 votes
1 answer

How to give the read power of a folder in Linux system?

Hi@akhtar, You can use chmod command in your ...READ MORE

answered Aug 13, 2020 in Linux Administration by MD
• 95,460 points
1,451 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 58,020 points
800 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 58,020 points
2,550 views
0 votes
1 answer

How to pass large records to map/reduce tasks?

Hadoop is not designed for records about ...READ MORE

answered Sep 25, 2018 in Big Data Hadoop by Frankie
• 9,830 points
1,568 views
0 votes
1 answer

Invalid method parameters for eth_sendTransaction

params needs to be an array, try {"jsonrpc":"2.0","method":"eth_se ...READ MORE

answered Sep 28, 2018 in Blockchain by digger
• 26,740 points
2,024 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP