Skip to main content
tssee
Inspiring
September 21, 2016
Answered

Open file txt

  • September 21, 2016
  • 1 reply
  • 1466 views

I would like to open a txt file located in the Documents folder

the folder is called data

and the file that is internally called data.txt

how could I do to open this file?

This topic has been closed for replies.
Correct answer JJMack

Using your script language file system functions.  Here is javascript code that creates a HTML text file in user temp then has the system open it in the users default HTML application which should be their default web browser.  The html text should redirect the browser the help on my web server.  If the user makes changes their changes will be written out when the dialog is processed because of the users action. In another area in the script.

try{

   var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");

   URL.open("w");

   URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');

   URL.close();

   URL.execute();   // The temp file is created but this fails to open the users default browser using Photoshop CC prior Photoshop versions work

}catch(e){

alert("Error, Can Not Open.");

};

A script that writes and reads its dialog setting into/from a file so the last setting used can be used again so the user does not have to remember  and set the settings they used the last time.  The user is able to change the settings displayed in the dialog. If the user does their changes will be written to the file when their action causes the dialog to be processed before before running it process the script will write out the users changes in another section in the script.

//Set First Time Defaults here

  var dfltCpys = 12; // default number of copies including the original

  var dfltPos = 4; // default Middle Center

  //End Defaults

  var Prefs ={}; //Object to hold preferences.

  var prefsFile = File(Folder.temp + "/RotateLayerAboutPreferences.dat");

  //If preferences do not exit use Defaults from above

  if(!prefsFile.exists){

  Prefs.Cpys  = dfltCpys;

  Prefs.Pos  = dfltPos;

  prefsFile.open('w');

  prefsFile.write(Prefs.toSource());

  prefsFile.close();

  }

  else{//Preferences exist so open them

  prefsFile.open('r');

  Prefs = eval(prefsFile.read());

  prefsFile.close();

  }

1 reply

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
September 21, 2016

Using your script language file system functions.  Here is javascript code that creates a HTML text file in user temp then has the system open it in the users default HTML application which should be their default web browser.  The html text should redirect the browser the help on my web server.  If the user makes changes their changes will be written out when the dialog is processed because of the users action. In another area in the script.

try{

   var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");

   URL.open("w");

   URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');

   URL.close();

   URL.execute();   // The temp file is created but this fails to open the users default browser using Photoshop CC prior Photoshop versions work

}catch(e){

alert("Error, Can Not Open.");

};

A script that writes and reads its dialog setting into/from a file so the last setting used can be used again so the user does not have to remember  and set the settings they used the last time.  The user is able to change the settings displayed in the dialog. If the user does their changes will be written to the file when their action causes the dialog to be processed before before running it process the script will write out the users changes in another section in the script.

//Set First Time Defaults here

  var dfltCpys = 12; // default number of copies including the original

  var dfltPos = 4; // default Middle Center

  //End Defaults

  var Prefs ={}; //Object to hold preferences.

  var prefsFile = File(Folder.temp + "/RotateLayerAboutPreferences.dat");

  //If preferences do not exit use Defaults from above

  if(!prefsFile.exists){

  Prefs.Cpys  = dfltCpys;

  Prefs.Pos  = dfltPos;

  prefsFile.open('w');

  prefsFile.write(Prefs.toSource());

  prefsFile.close();

  }

  else{//Preferences exist so open them

  prefsFile.open('r');

  Prefs = eval(prefsFile.read());

  prefsFile.close();

  }

JJMack