Open a file without extension

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: Tom, Kukurykus

oberown

Open a file without extension

Post by oberown »

How open a file without extension ?
I know the type of file.
I'm on a PC.

Sorry for my english
Andrew

Open a file without extension

Post by Andrew »

You need to explain better. Is the file an image? Why no extension?

You have a file: /c/test/photo1.jpg or C:\test\photo1.jpg

In either case, assuming you have Photoshop running, to open:

Code: Select allvar tFileName = '/c/test/photo1.jpg';
var tFile = new File (tFileName);
var tExists = tFile.exists;
if (tExists == false) alert('File ' + tFile.fsName + ' does not exist);
else {
  var ok = open(tFile);
  if (ok == false) alert('File ' + tFile.fsName + ' did not open);
}


This is not good code but maybe it is easy to understand.

Andrew
Guest

Open a file without extension

Post by Guest »

My name of file is image. It have no extension
xbytor

Open a file without extension

Post by xbytor »

The only way it might work is if you know is a jpeg, try using JPEGOpenOptions when you open it. Or just loop through all the different OpenOptions until one of them works.

The alternative is to rename (or copy and rename) the file using different extensions (.jpg, .pdf, .tif, etc...). Try opening each time until you find one that works.

Neither alternative is easy and the first may not even work.

Let us know how it goes.

ciao,
-X
Guest

Open a file without extension

Post by Guest »

JPEGOpenOptions don't exist but Photoshop.PsOpenDocumentType.psJPEGOpen exist. But I'don't manage to use this.