Page 1 of 1
creating hot key to add new folder
Posted: 22 Feb 2013 15:28
by Mac
I would like to be able to assign a key, such as the 'insert' key as a hotkey that would create a new subfolder in the currently selected folder. Does this functionality aready exist and I simply havent found it in the help system?
Any suggestions are appreciated.
Re: creating hot key to add new folder
Posted: 22 Feb 2013 16:16
by highend
E.g.:
Code: Select all
$folderName = input("Name of the new folder:", , "New Folder", "s");
if(exists("<curitem>") == 2) {
if($folderName != "") {
new("<curitem>\$folderName", "dir");
} else {
end(true);
}
} else {
new("<curpath>\$folderName", "dir");
}
Save it in your script dir (e.g. as "NewFolder.xys"), create a new user defined command
(via Menu - User - Manage Commands... - Load Script File) and assign a keyboard shortcut to it.
If the current selected item is a folder, it will create a new folder inside it, otherwise a new folder in the current directory.
If the dialog window is cancelled, nothing will be created.
Re: creating hot key to add new folder
Posted: 22 Feb 2013 17:10
by admin
I understood that he simply wants to assign INS to "New Folder". In that case:
Re: creating hot key to add new folder
Posted: 22 Feb 2013 18:07
by highend
that would create a new subfolder in the currently selected folder
Selected folder sounds like: The folder that is currently highlighted and not "the folder I'm in". At least to me

Re: creating hot key to add new folder
Posted: 22 Feb 2013 18:08
by admin
Yes, also. It could be both. Only Mac can tell.
Re: creating hot key to add new folder
Posted: 23 Feb 2013 16:55
by Mac
I want to start by thanking both of you for your suggestions. I have only been using XYplorer since version 11.90 and am still learning a lot about just what this program is capable of. I know that I am just starting to scratch the surface.
I started with highend's method.
I copied the scipt using copy and past into the file:
C:\Program Files (x86)\XYplorer\Scripts\NewFolder.xys
I then used Menu - User - Manage Commands and assigned the key to it.
When I place the cursor in a folder, or highlight a folder and press the hotkey (Ins) I get this:
[img]C:\!%20Temp\New%20Picture.png[/img]
When I click Continue, the pop-up disappears and nothing else happens.
If I right click on the "Continue Button" and select copy script, I get this:
// NewFolder.xys
load "C:\Program Files (x86)\XYplorer\Scripts\NewFolder.xys","New Folder";
I am not sure what I might have done wrong. Your instructions were very clear, but obviously I did something wrong. I am not a programmer of any kind myself, so I appraciate yout help.
I would like to see how this works in comparison to admins' response.
Using thiat method did allow me to reset the hot key used to create a new folder.
Getting the script to work would be nice. I could then use that to begin a learning process.
Again thank you both for your efforts.
-Mac
Re: creating hot key to add new folder
Posted: 24 Feb 2013 15:10
by RalphM
I didn't test it myself but it seems your call of the script has a parameter "New Folder" and with the provided script that doesn't work.
And just to make sure please check, that the first line of your script is indented!
Re: creating hot key to add new folder
Posted: 24 Feb 2013 17:57
by Mac
It does appear that all lines are indented 3 spaces.
I have attached it so you can look at it. I used notepad to create is a txt file and then renamed the extension to .xys.
Re: creating hot key to add new folder
Posted: 24 Feb 2013 18:53
by highend
It does appear that all lines are indented 3 spaces
That's ok.
RalphM already posted the solution. You're calling the script with a specific label:
Code: Select all
load "C:\Program Files (x86)\XYplorer\Scripts\NewFolder.xys","New Folder";
But the script should be called as it is. Just use:
Code: Select all
load "C:\Program Files (x86)\XYplorer\Scripts\NewFolder.xys";
and it should work properly.
Re: creating hot key to add new folder
Posted: 24 Feb 2013 19:30
by Mac
That did the trick. Blanking the 'Label:' field in Manage User Defined Commads made it run perfectly.
The script method was exactly what I was looking for.
I want to again Thank everyone who helped!
Really great program. Wish I had found it much earler!