diff --git a/io_export_directx_x.py b/io_export_directx_x.py
index c1e52f7e7d485885c4de36c4a5902215d8d05bda..64c25990c06f91eeb64c0e33af59bf4446d7dace 100644
--- a/io_export_directx_x.py
+++ b/io_export_directx_x.py
@@ -66,8 +66,15 @@ class DirectXExporterSettings:
 
 
 def LegalName(Name):
-    NewName = Name.replace(".", "_")
-    NewName = NewName.replace(" ", "_")
+    
+    def ReplaceSet(String, OldSet, NewChar):
+        for OldChar in OldSet:
+            String = String.replace(OldChar, NewChar)
+        return String
+    
+    import string
+    
+    NewName = ReplaceSet(Name, string.punctuation, "_")
     if NewName[0].isdigit() or NewName in ["ARRAY",
                                            "DWORD",
                                            "UCHAR",
@@ -1199,10 +1206,8 @@ class DirectXExporter(bpy.types.Operator):
     Verbose = BoolProperty(name="Verbose", description="Run the exporter in debug mode.  Check the console for output.", default=False)
 
     def execute(self, context):
-        #Append .x if needed
-        FilePath = self.filepath
-        if not FilePath.lower().endswith(".x"):
-            FilePath += ".x"
+        #Append .x
+        FilePath = os.path.splitext(self.filepath)[0] + ".x"
 
         Config = DirectXExporterSettings(context,
                                          FilePath,
@@ -1243,4 +1248,4 @@ def unregister():
 
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file