Page 1 of 1

Edit For a Script

Posted: 18 Aug 2018 06:12
by ZQS
it's a script by @SammaySarkar
for changing folders icons but it requires to chose the file icon manually
i want to change that and make it get the ico file from inside the folder
and alsow want to make it bulk (to change many folders at once)
But i'm new to this so any help :biggrin:
this is the original code

Code: Select all

"Iniconizer"
 if ("<curitem>" != '') && (exists("<curitem>") != 2) {
  $ico = getpathcomponent("<curitem>",file);
 } else {
  $ico = inputfile("<curpath>", /*"ico|exe|dll|icl|cpl"*/, "choose icon source");
  $ico = resolvepath($ico,"<curpath>", 1); //make relative to <curpath>
 }
  //if (exists("<curpath>\desktop.ini") != 1){new("<curpath>\desktop.ini",file);}
  setkey "$ico", "IconFile", ".ShellClassInfo", "<curpath>\desktop.ini",2;
  setkey "0", "IconIndex",".ShellClassInfo", "<curpath>\desktop.ini",2;
  attrstamp(h,1,"<curpath>\desktop.ini"); //desktop.ini hidden
  attrstamp(r,1, "<curpath>\"); //folder must be readonly to show icon
this what i tried to change it works but not good it needs the icon file to be selected other wise it chooses the folder name instead or run it twice to do the job as the ico file get selected by the filter after the 1st run

Code: Select all

"Iniconizer"

 if ("<curitem>" != '') && (exists("<curitem>") != 2) {
  $ico = getpathcomponent("<curitem>",file);
 } else {
  selfilter "*.ico;*.r##";
  $baseName = getpathcomponent($item, "file");
  $ico = resolvepath($baseName,"<curpath>", 1); //make relative to <curpath>
 }
  //if (exists("<curpath>\desktop.ini") != 1){new("<curpath>\desktop.ini",file);}
  setkey "$ico", "IconResource", ".ShellClassInfo", "<curpath>\desktop.ini",2;
  setkey "0", "IconIndex",".ShellClassInfo", "<curpath>\desktop.ini",2;
  attrstamp(h,1,"<curpath>\desktop.ini"); //desktop.ini hidden
  attrstamp(r,1, "<curpath>\"); //folder must be readonly to show icon
  //openwith "notepad", , "<curpath>\desktop.ini";
  //uncomment above to open the ini after creation

Re: Edit For a Script

Posted: 18 Aug 2018 06:47
by highend
You mean something like this?

Code: Select all

"Iniconizer"

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        if (exists($folder) != 2) { continue; }
        $icon = gpc(quicksearch("*.ico /n /limit=1", $folder), "file");
        $ini  = "$folder\desktop.ini";
        if (!$icon) { status "No .ico file found, aborted!", "8B4513", "stop"; end true; }
        if (exists($ini) != 1) { writefile($ini, , , "utf8"); }
        setkey $icon, "IconResource", ".ShellClassInfo", $ini, 2;
        setkey "0", "IconIndex", ".ShellClassInfo", $ini, 2;
        attrstamp("hs", , $ini);
    }
    status "Done...";
You need to select all the folders for which the desktop.ini should be created / modified!
It uses the first found .ico file from each folder...

Re: Edit For a Script

Posted: 18 Aug 2018 07:04
by ZQS
highend wrote:You mean something like this?

Code: Select all

"Iniconizer"

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        if (exists($folder) != 2) { continue; }
        $icon = gpc(quicksearch("*.ico /n /limit=1", $folder), "file");
        $ini  = "$folder\desktop.ini";
        if (!$icon) { status "No .ico file found, aborted!", "8B4513", "stop"; end true; }
        if (exists($ini) != 1) { writefile($ini, , , "utf8"); }
        setkey $icon, "IconResource", ".ShellClassInfo", $ini, 2;
        setkey "0", "IconIndex", ".ShellClassInfo", $ini, 2;
        attrstamp("hs", , $ini);
    }
    status "Done...";
You need to select all the folders for which the desktop.ini should be created / modified!
It uses the first found .ico file from each folder...
it's working like a charm
thanks alot @highend