Chris
Chris

Reputation: 3698

How can I rename files of which I don't know the extension?

I have a directory with these files:

one.txt
two.mp3
three.bmp

Is there any way to rename files using MoveFile() but without specifying the extension of the file (all the files have different filenames)?

If not, how can I rename these files to anything I want, when I only know the

one
two
three

?

Upvotes: 0

Views: 109

Answers (2)

Kaslai
Kaslai

Reputation: 2505

You'll have to use the underlying OS API to scan through the directory for files and compare each filename with your desired prefix. Here is another question that shows you how to list the contents of a directory in Windows.

Upvotes: 3

Karthik T
Karthik T

Reputation: 31972

Once you know prefix read the filelist of the directory and find a valid filename with that prefix, and use that filename with the function.

Upvotes: 2

Related Questions