Customize Folder

Discuss and share scripts and script files...
Post Reply
TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Customize Folder

Post by TheQwerty »

This is a little script I wrote to make giving a folder a custom icon quicker and avoid going through the Windows Customize Folder dialogs.


It will create a desktop.ini file pointing to icon 0 of the selected and focused item.
If desktop.ini already exists the new file will have a suffix number in accordance with batch rename, you'll have to decide which you want to keep after the script completes.
Then it changes the attributes of the file and folder to apply the customization.

If you want the change to show in the tree you'll need to do a rebuild tree or add #484; to the end of this script.

Code: Select all

"Customize Folder"
 //Temporarily change XY settings.
 Setting("AutoRefresh", "0");
 Setting("ResortAfterRename", "0");

 //Store the clipboard so it can be restored.
 Set("%cb%","<clipboard>");

 //Put new desktop.ini contents on clipboard.
 CopyText("[.ShellClassInfo]<br>IconFile=<curname><br>IconIndex=0");
 //Paste clipboard as new textfile.
 #219;

 //Restore the clipboard.
 CopyText("%cb%");

 //Use batch rename so that if needed a suffix is used.
 Rename("bat","desktop.ini/e","");
 
//Refocus the list to ensure the variables are picked up.
 Focus("List");
 //Change the desktop.ini's attributes to +Hidden, +System, -Archive
 Open("""attrib"" +H +S -A ""<curitem>""", "w");
 //Change the current folder's attributes to +Read-only
 Open("""attrib"" +R ""<curpath>""", "w");

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Post by TheQwerty »

Condensed:

Code: Select all

Set("$cd", "<curpath>");
 SetKey("<curname>", "IconFile", ".ShellClassInfo", "$cd\desktop.ini");
 SetKey("0", "IconIndex", ".ShellClassInfo", "$cd\desktop.ini");
 Open("""attrib"" +H +S -A ""$cd\desktop.ini""", "w");
 Open("""attrib"" +R ""$cd""", "w");

admin
Site Admin
Posts: 66254
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

TheQwerty wrote:Condensed:

Code: Select all

Set("$cd", "<curpath>");
 SetKey("<curname>", "IconFile", ".ShellClassInfo", "$cd\desktop.ini");
 SetKey("0", "IconIndex", ".ShellClassInfo", "$cd\desktop.ini");
 Open("""attrib"" +H +S -A ""$cd\desktop.ini""", "w");
 Open("""attrib"" +R ""$cd""", "w");
Yep, works! Nice one! :D

Next will come scripting commands for time and attr stamping...

Post Reply