How to get all the file names in the current directory?

My goal is to create a program that renames all files in the current working directory so that they don't have spaces, any special characters or any accented characters (for example, É became E). I plan to use int rename(const char *oldname, const char *newname);. My problem is how to get the files in the current working directory? I would like the executable file that I created to be placed in a folder with files with bad names and run it, and all the files should be renamed.

Regardless of the platform, a solution would be preferable, otherwise I use Windows 7 Enterprise 32bit.

This question is not a duplicate, because I do not know the path for opendir ("c:\\src\\");in any directory from which the program is running.

+1
source share
2 answers

Here is a sample code for this:

http://bytes.com/topic/c/answers/869208-list-files-directory

You mainly use these APIs: FindFirstFileandFindNextFile

For a cross-platform solution, see findfirst()andfindnext()

+1
source

The option is to use opendir ("."), This will open the current directory.

0
source

All Articles