[Mac] Linking to a folder placed on a NAS

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Kukurykus, Tom, xbytor

Scriptor
Posts: 14
Joined: Tue Oct 01, 2019 12:07 pm

[Mac] Linking to a folder placed on a NAS

Post by Scriptor »

Hey!
I have a script that needs to run on both Windows & Mac, and was planning on using something like this (note that the if-condition is just to illustrate what I mean) ;

Code: Select all

if ("Windows") {var testFolder = new Folder("file://///SERVERNAME//Storage//Resources//Test");}
if ("Macintosh") {var testFolder = new Folder("~Storage//Resources/Test");}
var fileList = testFolder .getFiles(/\.(jpg|tif|psd|bmp|gif|png|)$/i); 
I cannot get the Mac to register any images in the specified folder however - and I have tried some different ways of doing it ("file://", "afp://", ect ect). Does anyone have any solution to this?
Thanks!

User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: [Mac] Linking to a folder placed on a NAS

Post by jaydoubleyou80 »

You said they are just examples, but your Mac file location is missing a slash after the tilde, and has an extra after Storage.

Code: Select all

if ("Macintosh") {var testFolder = new Folder("~/Storage/Resources/Test")};
if the location is on a NAS drive though, you'll want something more like this:

Code: Select all

if ("Macintosh") {var testFolder = new Folder("/Volumes/SERVERNAME/Storage/Resources/Test")};
On a Mac when you reference the file location using a tilde, you are starting in your user folder (Macintosh HD/Users/currently logged in user).

Scriptor
Posts: 14
Joined: Tue Oct 01, 2019 12:07 pm

Re: [Mac] Linking to a folder placed on a NAS

Post by Scriptor »

Yes - I am not at all well-oriented in using Mac - I did not know that a tilde was used like that - thank you for pointing that out to me!

Okay, I've changed the folder location reference to the one listed below (I've just changed the servername). The folder in question contains 6 different images, and then I try it out on a Windows machine I get a string in the alert box containing searchway to the first image.
But when I try it out on a Mac I get an alert box that says "undefined". I know that the Mac has a connection to the server since the script is located on the same NAS.

Am I missing something obvious here?:/

Code: Select all

if (StringMatches("Win", $.os)) {var testFolder = new Folder("file://///SERVERNAME//Storage//Resources//Test");}
if (StringMatches("Mac", $.os)) {var testFolder = new Folder("/Volumes/SERVERNAME/Storage/Resources/Test");}

var fileList = testFolder.getFiles(/\.(jpg|tif|psd|bmp|gif|png|)$/i); 
alert(fileList[0]);	//Comes out undefined when using Mac

function StringMatches(searchstring, StringToCheck) {
	try {
		var IfCase = StringToCheck.toString();
		var checkstring = IfCase.indexOf(searchstring);
		if (checkstring==-1){return false;}
		if (checkstring >= 0){return true;}
		return false;
	} catch(error) { alert(error); }
}

User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: [Mac] Linking to a folder placed on a NAS

Post by jaydoubleyou80 »

I have the same issue with Windows machines, I just don't work with them enough to be well versed.

Try putting one more slash after your file path in the Mac testFolder variable.

Code: Select all

if (StringMatches("Mac", $.os)) {var testFolder = new Folder("/Volumes/SERVERNAME/Storage/Resources/Test/")}
I also don't think you need new Folder, but it doesn't seem to have any negative affect. Both of these return a proper value for me.

Code: Select all

if (StringMatches("Mac", $.os)) {var testFolder = Folder("/Volumes/SERVERNAME/Storage/Resources/Test/")}

Scriptor
Posts: 14
Joined: Tue Oct 01, 2019 12:07 pm

Re: [Mac] Linking to a folder placed on a NAS

Post by Scriptor »

I am sure you will get used to them someday if you aim for it:)

Hmm, no it doesn't seem to work for me.. And i can't find any mention of it in the scriptingreference.
When I look at the action that contains the script in Photoshop, I can see that the searchway is

Code: Select all

File: /Volumes/Storage/Resources/Test/testscript.jsx

And that it doesn't state the "SERVERNAME" in the searchway. I tried running the script without the servername, with IP adress to it, as AFP link and other solutions as well, but it doesn't seem to work either:/

Anyhow - thanks for trying to help me, jaydoubleyou80:)

User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: [Mac] Linking to a folder placed on a NAS

Post by jaydoubleyou80 »

Sorry it hasn't actually been that helpful. I'm at a loss because besides adding / after the folder name in the Mac path, I copied your code from your previous comment exactly and just swapped out the path for one to a drive I have mounted via my network. The script executed just how you want.

Does your server name have any spaces in it? I'm not sure if PCs need underscores for spaces in a path, but Macs do not, they just use the space.

Besides that, I'm kind of stumped ¯\_(ツ)_/¯

Scriptor
Posts: 14
Joined: Tue Oct 01, 2019 12:07 pm

Re: [Mac] Linking to a folder placed on a NAS

Post by Scriptor »

Not your fault - as you said it should work. It might be some firewall or something on my company network or that the server isn't correctly configured, but I doubt it:/

The server is named in this format; "COMPANYNAME-IMAGE-BANK", without spaces. The whole searchway contains no spaces. I tried this;

Code: Select all

var res = new File(testFolder+'/Test0.png')
open(res);
But it resulted in "Error 1233:Expected a reference to an existing File/Folder". Works flawless on Windows though - yay;)
Well thank you for your time - I'll check with our IT department if there is something that can be done.
Have a great weekend!

Scriptor
Posts: 14
Joined: Tue Oct 01, 2019 12:07 pm

Re: [Mac] Linking to a folder placed on a NAS

Post by Scriptor »

Update: We solved the issue by using another server. Thank you for all your help!

User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: [Mac] Linking to a folder placed on a NAS

Post by jaydoubleyou80 »

That's great! It's always nice when a seemingly insolvable problem turns out to be something like that. I'm still curious what it was about that server that prevented it from working, but at least your issue is fixed.

User avatar
txuku
Posts: 129
Joined: Thu Jan 01, 1970 12:00 am

Re: [Mac] Linking to a folder placed on a NAS

Post by txuku »

Bonjour

I don t use Mac ( allergic )!!! :)

But it seems to me - often seen in scripts - that you have to use the formula:
#target photoshop // formula for Mac
app.bringToFront ();