Jump to content

Crushed by rogue newline when assembling link

Recommended Posts

I have spent a day and a half wrestling with a new workflow which involves:

  • extracting part of the path of a file;
  • adding some text in the workflow; and
  • putting the two together to form a link of sorts.

Everything is so near to working but I am haunted by a rogue newline which appears as part of the first bullet point (and also happens if I try to achieve the same result using AppleScript). I have tried absolutely everything to dispose of it—short of an axe—but insanity now looms.


If you wish to rescue me or laugh at my incompetence here is a transfer.sh link to a short workflow that demonstrates the problem.


I despair…



Link to comment

AppleScript always adds a newline at the end, so you’ll have no luck there. It is possible to avoid the newline but it’s a bit of a convoluted solution in which you have to invoke the Objective-C bridge. As for the shell code, you can append | tr -d '\n' which will delete all newlines.

But in both cases you could also use a Transform Utility—its default is to trim whitespace, which includes stripping newlines from the ends.


Edited by vitor
Link to comment

Many thanks for the kind help, Vitor. Sanity is restored. I'd messed around with the tr command but incompetence prevented it from providing a solution. I had entirely forgotten the Transform Utility <sigh>.


As a reward for your kindness you will receive a free copy of the completed workflow… Oh, wait…all my workflows are free: sorry! 😀



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...