Why I created it:
Daily I copy various files to various usb drives to use around my place of work. Usually I plug in the drives and I need to browse around to figure out what drives letters were assigned to the usb drives. Then I open a tab for each usb drive so I can then go to the 'source' tab and copy certain files to the various usb tabs via drag n drop. The files change so its not possible yet to automate the whole process.
My first thought was 'it would be nice to have a tab auto-open when I plugged in a usb drive'. Since that is not possible I thought I would try to automate the tabs via a script. This is what I have so far.
I run this from an item in the catalog. I don't use the tree or anything, I just have the catalog with all kinds of things in it.
The script:
Code: Select all
$drives = get("drives",2);
foreach($tabroot, $drives, "|") {
$index = tab("newb",$tabroot);
$name = trim($tabroot, ":\");
tab("rename","RD:$name|<xyicons>\shapes\rd.ico",$index);
tab("sethome",$tabroot,$index);
}
Code: Select all
Rem Drives Tabs|<xyicons>\shapes\rd.ico
The first line of the script scans for drives of the type removable and puts that into the variable $drives
The foreach breaks the list of drives in $drives apart one by one. Each drive is stored in $tabroot during each pass of the loop
The next line creates the new background tab and stores the index of the new tab in the variable $index
The next line cleans up the drive name by trimming off the ":\". The result is just the drive letter. This is stored in $name
The next line renames the tab using the $name variable and sets a custom icon to make it look pretty
The last line sets the tabs 'home' to the root of the drive that is in $tabroot
To customize:
You can change the name of the tab by changing the "RD:$name|<xyicons>\shapes\rd.ico" part. The RD is just something for Removable Drive, The $name is the drive letter, and the |<xyicons>.... is just the icon.
The future:
This seems to work fine. If anyone has any ideas just let me know.
I also thought it would be cool to figure out a way to read the drive, or volume, label and have that in the name of the tab. Then when using multiple tabs each one is better identified.
Enjoy, Shawn
XYplorer Beta Club