Tested with versions 9.0.0, 10.0.2 and 10.3.0, all under OS X 10.10.5. and Linux

The drag-and-drop front-end functionality also results in $Failed.

Surprisingly, Importing, JPEGs, TXTs, and XLSX work just fine!

(* Initialization *)
text = "Uh oh, this could be a bug";
fileNameTemplate = StringTemplate["s`1`mple file.`2`"];
extensions = { "pdf", "txt", "jpeg", "xlsx"};



(* The list of "a"s used in the test *)
Table[FromCharacterCode@a, {a, 1, 1000}];
as = Select[%, RemoveDiacritics@# == "a" &]

{"a", "à", "á", "â", "ã", "ä", "å", "ā", "ă", "ą", "ǎ", "ǟ", "ǡ", "ǻ", "ȁ", "ȃ", "ȧ", "ɐ", "ɑ", "ɒ"}

(* Exporting files, no failures so far *)
Map[# -> Export[fileNameTemplate @@ #, text] &, Outer[List, as, extensions], {2}]

{a,pdf}->sample file.pdf,
{a,txt}->sample file.txt,
{a,jpeg}->sample file.jpeg,
{a,xlsx}->sample file.xlsx
{ɒ,pdf}->sɒmple file.pdf,
{ɒ,xlsx}->sɒmple file.xlsx

(* Re-importing files *)
res = Map[# -> Import@# &, GatherBy[FileNames["*file*"], FileBaseName], {2}];
Drop[res, -1];
%[[-4 ;; -3, 1 ;; 4]] // Flatten // Column

sample file.jpeg-> #image here#
sample file.pdf->{#image here#}
sample file.txt->Uh oh, this could be a bug
sample file.xlsx->{{{Uh oh, this could be a bug}}}
sɐmple file.jpeg-> #image here#
sɐmple file.pdf->$Failed
sɐmple file.txt->Uh oh, this could be a bug
sɐmple file.xlsx->{{{Uh oh, this could be a bug}}}

Only PDFs fail. I've tried a bunch of different $CharacterEncodings, but the only solution so far was to rename the file, work with it, then rename it back, as in this (very rudimentary) example

withFunnyName[filePath_, fun_] := 
 Module[{origName = filePath, tempName, res},
  tempName = CreateTemporary[];
  RenameFile[origName, tempName];
  res = fun@tempName;
  RenameFile[tempName, origName];


What could I be doing wrong? Some system configurations?

  • 4
    $\begingroup$ This would seem to be a bug to me, and it can be tested most simply by the fact that Import[Export["test_ǡ.png", "Hello"]] works while Import[Export["test_ǡ.pdf", "Hello"]] returns $Failed $\endgroup$ – Jason B. Feb 12 '16 at 13:16
  • $\begingroup$ I suspected that, but I'm always wary of blaming the system... (You actually came! Thanks!) $\endgroup$ – Aisamu Feb 18 '16 at 19:04
  • $\begingroup$ Dedicated thread: "How to workaround failures with Unicode filepaths?" $\endgroup$ – Alexey Popkov Apr 30 '17 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.