Bytes2048
Bytes2048

Reputation: 344

Changing the display name of a file

How can I change the display name of a file using Python?

Details:

To be precise, I want to hide the file extension of a file so that textfile.txt is seen as textfile only, without actually removing the file extension.

EDIT: The display name of a file looks like this:

Image

And I want it to look like this:

Image

Upvotes: 0

Views: 101

Answers (1)

mao95
mao95

Reputation: 1122

What you want is

import os
print(os.path.splitext("/path/to/textfile.txt")[0])

The output will be

/path/to/textfile

EDIT: from your last edit i figured that what you're looking for is to hide extensions directly in the OS using Python. Well, this is more a task to do modifying your system settings, i don't think that you will be able to change this type of system settings directly from Python.

Upvotes: 1

Related Questions