Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert Selected Graphics Folder to Binary Encoded Files - Ready Made Script

Enthusiast ,
Aug 19, 2022 Aug 19, 2022

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?

Best
Mohammad Hasanin
TOPICS
Scripting
384
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 20, 2022 Aug 20, 2022

Hi @M.Hasanin, thanks so much for sharing your script. 🙂

- Mark

Translate
Community Expert ,
Aug 20, 2022 Aug 20, 2022

Hi @M.Hasanin, thanks so much for sharing your script. 🙂

- Mark

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 22, 2022 Aug 22, 2022
LATEST

@m1b you are very welcome 🙂

Best
Mohammad Hasanin
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines