Copy link to clipboard
Copied
Hi All , this is not a question, its a script i want to share with you, its contribution script that maybe it will be useful for someone who need it, i need to convert many images to binary and only found scripts one by one to encode one image per time, so i wrote a script that will automatically convert all images to binary encoded text files, here it is :
//Convert Selected Graphics Folder to Binary Encoded Files
//Written By : Mohammad Hasanin (M.Hasanin) in 19/8/2022
//Ask User Where is the Files
var selectedFolder = Folder.selectDialog("Select a folder for Encoding Graphics Files");
//Supporting Multiple Format
var GrphFiles = selectedFolder.getFiles(/\.(?:png|gif|jpg|jpeg|bmp|tif|psd)$/i);
for(var i=0;i<GrphFiles.length;i++)
{
//Collect Files, Files Names
var myFilesName = GrphFiles[i].name;
var myFiles = GrphFiles[i];
//One Hit to Save new File with Same Name of Original Replacing the Extension with (*.txt)
var myEncodedGrphFiles = new File(selectedFolder.fullName + "/"+myFilesName.replace (/\.(png|gif|jpg|jpeg|bmp|tif|psd)$/,'')+".txt");
//Open and Encode
myFiles.open ("r");
myFiles.encoding = "binary";
var temp = myFiles.read();
myFiles.close();
//Write Encoded Graphic Files
myEncodedGrphFiles.open("w");
myEncodedGrphFiles.write(temp.toSource ());
myEncodedGrphFiles.close();
}
and for all the expert engineers that i learned from you, thanks a lot and im still learning! , and will be happy to see many ways to skin the cat!, any suggestion or additional point of view to enhance?
Hi @M.Hasanin, thanks so much for sharing your script. 🙂
- Mark
Copy link to clipboard
Copied
Hi @M.Hasanin, thanks so much for sharing your script. 🙂
- Mark
Copy link to clipboard
Copied
@m1b you are very welcome 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now