Reputation: 344
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:
And I want it to look like this:
Upvotes: 0
Views: 101
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