Skip to main content
October 3, 2008
Question

forcing non-standard extention

  • October 3, 2008
  • 4 replies
  • 549 views
I work with "device independent bitmap" (DIB) files, which PsCS2 recognizes as BMP files. Opening them with a script is no problem but Ps wants to save them as filename.bmp files instead of filename.dib. The code I use for saving is:

DocRef.saveAs( new File( resultsFolder + "/" + fileNames[fileIndex] + "_Hm-and-Mt.dib" ), bmpSaveOptions, true );

and bmpSaveOptions are defined as:

var bmpSaveOptions = new BMPSaveOptions();
bmpSaveOptions.alphaChannels = false;
bmpSaveOptions.depth = BMPDepthType.EIGHT;
bmpSaveOptions.osType = OperatingSystem.WINDOWS;
bmpSaveOptions.rleCompression = false;

Does anyone know if I can force the extension'dib'?

TIA :)
This topic has been closed for replies.

4 replies

October 6, 2008
> fileObj.rename( resultsFolder + "/" + fileNames[fileIndex] + "_Hm-and-Mt.dib" );

> let see if I have this correct ...

Works perfect! Thanx a lot!
MarkWalsh
Inspiring
October 6, 2008
The rename function requires a file name, not a file path, so

fileObj.rename( fileNames[fileIndex] + "_Hm-and-Mt.dib" );

should do it.
October 4, 2008
Thanx for your response! Being away from my Ps workstation, let see if I have this correct ...

fileObj = new File( resultsFolder + "/" + fileNames[fileIndex] + "_Hm-and-Mt.bmp" );
DocRef.saveAs( fileObj, bmpSaveOptions, true );
fileObj.rename( resultsFolder + "/" + fileNames[fileIndex] + "_Hm-and-Mt.dib" );

... or, should the fileObj be related simple to the filename, excluding the path?

cheerios :)
MarkWalsh
Inspiring
October 3, 2008
You may not be able to force the extension, but after saving the file, you should be able to use the 'rename' function of the File object

rename
fileObj.rename (newName)
Renames the associated file. Returns true on success.
Does not resolve aliases, but renames the referenced alias or shortcut
file itself.
newName The new file or folder name, with no path.