Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Full Path Name to File on OSX El Capitan

Posted on 2016-08-10
3
Medium Priority
?
73 Views
Last Modified: 2016-08-10
Hi

I need to programmatically access a .TXT file via Javascript on my MacBook Air (OSX 10.11.6). I am a PC user and am not familiar with the file structure on a mac.

1. If I place the .TXT file on my desktop, what will the path be?
2. If I place the .TXT file in my Documents folder, what will the path be?

FYI, here is the simple Javascript that I'm playing with just now (I would prefer the path to be absolute and not a relative path as I'm not sure where the Javascript will be triggered from yet).

try{
myPath = "~/Desktop/source.txt";
$.evalFile(myPath);
eval(thisComp.name)[0];
}catch(err){
"MISSING";
}


Thanks very much for your help!
0
Comment
Question by:everycloud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Assisted Solution

by:strung
strung earned 668 total points
ID: 41749925
The simplest way to find a path name on a Mac is to open a terminal window and drag and drop the file into the window. This will add the full path name to the window and you can copy and paste it.
0
 
LVL 37

Assisted Solution

by:bbao
bbao earned 668 total points
ID: 41749930
the full pathname is '/users/your name/desktop/source.txt' where 'yourname' is your actual username. or simply use 'users/yourname' to replace all '~' in your code.
0
 
LVL 41

Accepted Solution

by:
Eoin OSullivan earned 664 total points
ID: 41750175
OK .. if this script is ONLY on your MacBook and ONLY when your specific user is logged in then you can use the ABSOLUTE paths which are as follows .. (replace USERNAME with the user you login with)
/Users/USERNAME/Desktop/

Open in new window

/Users/USERNAME/Documents/

Open in new window


However if there is a chance that the script will be used on other computer or by other users the relative path is perfectly good.  The tilde (~) character which == Home folder for the currently logged in user is a completely standard Unix format and almost ALL applications and scripts can quite happily work with it and you can use the "~/" instead of "/Users/USERNAME/" almost everywhere
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question