Why am I getting file name can't be used error?

Is there any reason I cant name a file this:


The Lonely House on Adachi Moor in Northern Japan Yoshitoshi 1885.png


There are no punctuation marks.


iMac 27″ 5K, macOS 10.14

Posted on Jan 4, 2023 7:18 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 4, 2023 8:14 PM

I wonder if 10 spaces is too many, "The Lonely House on AdachiMoor inNorthernJapanYoshitoshi 1885.png" worked.

6 spaces


"The Lonely House on Adachi Moor in Northern Japan Yoshitoshi 1885.png" did not here either.

10 spaces


"The Lonely House on Adachi_Moor_in_Northern_Japan_Yoshitoshi_1885.png" worked.


Nope, nit to many spaces...


Aha, in a Hex editor it looks like 2 of your spaces are actually Linefeeds!


"The Lonely House on Adachi

Moor in Northern Japan

Yoshitoshi 1885.png"


22 54 68 65 20 4C 6F 6E 65 6C 79 20 48 6F 75 73 65 20 6F 6E 20 41 64 61 63 68 69 0A 4D 6F 6F 72 20 69 6E 20 4E 6F 72 74 68 65 72 6E 20 4A 61 70 61 6E 0A 59 6F 73 68 69 74 6F 73 68 69 20 31 38 38 35 2E 70 6E 67 22

16 replies
Question marked as Top-ranking reply

Jan 4, 2023 8:14 PM in response to onefiftymph

I wonder if 10 spaces is too many, "The Lonely House on AdachiMoor inNorthernJapanYoshitoshi 1885.png" worked.

6 spaces


"The Lonely House on Adachi Moor in Northern Japan Yoshitoshi 1885.png" did not here either.

10 spaces


"The Lonely House on Adachi_Moor_in_Northern_Japan_Yoshitoshi_1885.png" worked.


Nope, nit to many spaces...


Aha, in a Hex editor it looks like 2 of your spaces are actually Linefeeds!


"The Lonely House on Adachi

Moor in Northern Japan

Yoshitoshi 1885.png"


22 54 68 65 20 4C 6F 6E 65 6C 79 20 48 6F 75 73 65 20 6F 6E 20 41 64 61 63 68 69 0A 4D 6F 6F 72 20 69 6E 20 4E 6F 72 74 68 65 72 6E 20 4A 61 70 61 6E 0A 59 6F 73 68 69 74 6F 73 68 69 20 31 38 38 35 2E 70 6E 67 22

Jan 5, 2023 9:09 AM in response to onefiftymph

onefiftymph wrote:

Ok interesting thanks. Don't think I have a hex editor. Maybe I could try dropping it into TextEdit and converting to plain text.


That particular text string is ASCII, with ASCII control characters / control codes. No UTF-8 or other encoding. (Yeah, technically, ASCII is a proper subset of UTF-8.) That text string would be entirely renderable on a computer from the 1970s. And it would still have derailed apps back then that weren’t expecting embedded controls, too.


The question then becomes where the formatting—the control characters—came from, and how to remove that. I’d suspect cut-and-paste from somewhere. What’s the input source here?


Depending on the context, pasting with Command-Shift-V might clear the control characters, or a trip through the command-line tools such as tr or sed or ilk, or otherwise. Perl and Python can also easily do this filtering, but then you have to install and update those.


The full old-school approach is the ansi2txt tool or similar, which also removes ANSI control sequences..


Or removing the control codes in the input. (Which is why I’d asked about that, above.)


There’s probably either a droplet around or one could be created to get (only) the desired stuff into the pasteboard, either in some tool or in zsh or bash using pbcopy and pbpaste. There are related scripts around, too.

Jan 7, 2023 1:36 AM in response to MrHoffman

When AppleScript wraps long text in a display alert, it uses line feeds for that purpose. I could duplicate those linefeeds here with an AppleScript display alert and by typing the same text as displayed on the OP dialog, or the first paragraph of Steve Job's Stanford address. A screenshot later and selecting the text, copying it to the clipboard and a little Terminal action proves it:


pbpaste | hexdump -C


Jan 6, 2023 7:20 PM in response to onefiftymph

onefiftymph wrote:

It was copy pasted from a website. surprised to hear that invisible "linefeeds" got added somewhere along the way...


The linefeeds ␊ were likely present in what was copied—in the source—and were not added later.


A carriage return ␍ followed by a linefeed ␊ is one of the ways how ASCII text files are formatted, though there are other ways. It's quite possible the website used these ASCII control characters, rather than HTML tags, for instance.


The basic operations of carriage return ␍ and linefeed ␊ go back to the era of manual typewriters, too. In normal operations, the lever causes both a carriage return ␍ and a linefeed ␊. Computing carried that usage over. This is a very old part of computing.

Jan 4, 2023 8:23 PM in response to onefiftymph

onefiftymph Said:

"onefiftymph: Why am I getting file name can't be used error?: Is there any reason I cant name a file this: The Lonely House on Adachi Moor in Northern Japan Yoshitoshi 1885.png There are no punctuation marks."

-------


Thank you for the screenshot.


File Extension:

Rid of the apostrophe after the png extension. Report back if that does the trick.


Jan 7, 2023 10:03 AM in response to VikingOSX

VikingOSX wrote:

When AppleScript wraps long text in a display alert, it uses line feeds for that purpose. I could duplicate those linefeeds here with an AppleScript display alert and by typing the same text as displayed on the OP dialog, or the first paragraph of Steve Job's Stanford address. A screenshot later and selecting the text, copying it to the clipboard and a little Terminal action proves it:

pbpaste | hexdump -C


That’s entirely true, but the word wrapping in the dialog boxes is usually better than what was included above.


That wrapping would usually place Yoshitoshi a line earlier.


It was that errant spacing (yeah, H&J) that sent me toward embedded controls.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Why am I getting file name can't be used error?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.