Skip to main content
Participant
June 21, 2024
Question

PLEASE HELP! Need to open and save Targa files with different extension than .TGA

  • June 21, 2024
  • 2 replies
  • 1278 views

I utilize software that differentiates Targa files by the extension.

Files with .1 insteat of .TGA are front views, and files with .2 are side views, etc.

These are Targa 16bit files.

I need to be able to load .1 files in Photoshop, edit and save as an extension other than .TGA.

PLEASE HELP.

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
June 22, 2024

@Gregory381864901nnt – Here are 2 Photoshop scripts.

 

Script 1 of 2: 

Renames a folder of custom extension files from "image.1", "image.2" etc. to "image.1.tga" "image.2.tga" etc.

 

/*
Script 1 of 2 - Rename TGA to Open in Photoshop.jsx
v1.0 - 22nd June 2024, Stephen Marsh
Renames a folder of custom extension files from "image.1", "image.2" etc. to "image.1.tga" "image.2.tga" etc.
https://community.adobe.com/t5/photoshop-ecosystem-discussions/please-help-need-to-open-and-save-targa-files-with-different-extension-than-tga/td-p/14695748
*/

#target photoshop

    (function () {

        var theInput = Folder.selectDialog("Please select the folder:"),
            theFiles = theInput.getFiles(/\.\d+$/i),
            theFile,
            theName;

        for (var i = 0; i < theFiles.length; i++) {
            theFile = theFiles[i];
            theName = theFile.name.replace(/(^.+)(\.)(\d+)/, '$1.$3.tga');
            theFile.rename(theName);
        }

        /*
        // Open the files
        var theFiles = theInput.getFiles(/\.tga$/i);
        for (var i = 0; i < theFiles.length; i++) {
            var openFiles = app.open(File(theFiles[i]));
        }
        */

    })();

 

 

Script 2 of 2: 

Renames a folder of files from "image.1.tga" "image.2.tga" etc. to "image.1" "image.2" removing the standard .tga extension
 
/*
Script 2 of 2 - Rename TGA to Open in Photoshop.jsx
v1.0 - 22nd June 2024, Stephen Marsh
Renames a folder of files from "image.1.tga" "image.2.tga" etc. to "image.1" "image.2" removing the standard .tga extension
https://community.adobe.com/t5/photoshop-ecosystem-discussions/please-help-need-to-open-and-save-targa-files-with-different-extension-than-tga/td-p/14695748
*/

#target photoshop

    (function () {

        var theInput = Folder.selectDialog("Please select the folder:"),
            theFiles = theInput.getFiles(/\.tga$/i),
            theFile,
            theName;

        for (var i = 0; i < theFiles.length; i++) {
            theFile = theFiles[i];
            theName = theFile.name.replace(/(^.+)(\.[^\.]+$)/, '$1');
            theFile.rename(theName);
        }

    })();

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Participant
July 2, 2024

Thanks for the information but that will not work due to the software that loads the files is looking to assign each to a side. Front = .1 Side = .2 etc. The prefix is UPC so this is a systematic funtion of the software we use to create Planograms (if your familiar with that term). Another software product had a configuration setting ...see attached

 

Greg P
Stephen Marsh
Community Expert
Community Expert
July 2, 2024
quote

Thanks for the information but that will not work due to the software that loads the files is looking to assign each to a side. Front = .1 Side = .2 etc. The prefix is UPC so this is a systematic funtion of the software we use to create Planograms (if your familiar with that term). Another software product had a configuration setting ...see attached

 


By @Gregory381864901nnt


Did you actually try the 2 scripts?

 

If so, please explain why this doesn't work as I tested them in Windows Photoshop and they worked for me.

 

I don't know if one can assign non-standard image extensions to Photoshop which is why I provided the 2 scripts.

Participant
June 21, 2024

The files are actually 32bit Targa.

Greg P
Stephen Marsh
Community Expert
Community Expert
June 22, 2024

Working with non-standard file extensions will require you to jump through some hoops, particularly so in Windows.

 

You should be able to save valid TGA files from Photoshop by changing the extension from .tga to .1 etc.

 

The issue is opening such files in Photoshop for Windows.

 

I would suggest that you Batch Rename the images using Adobe Bridge:

 

 

Regular Expression Find:

(^.+)(\.)(\d+)

 

Replace With:

$1.$3.tga

 

Where "test.1" or "test.2" etc. would be renamed to "test.1.tga" or "test.2.tga" which now has a valid file extension for opening into Photoshop on Windows, while preserving the original number designation for the view. 

 

After saving the files from Photoshop, you would need to remove the .tga to return to the non-standard naming.

 

Bridge makes it very difficult to Batch Rename without using a valid extension, I know that it can be done but it escapes me at this time. You could possibly use another bulk renaming utility to remove the .tga file extension. Last resort would be manually remove the .tga extension.

 

Another alternative would be a custom script.

 

I'm interested to see what others come up with!