creating hot key to add new folder

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Mac
Posts: 5
Joined: 15 Feb 2013 18:59

creating hot key to add new folder

Post 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.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: creating hot key to add new folder

Post 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.
One of my scripts helped you out? Please donate via Paypal

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

Re: creating hot key to add new folder

Post by admin »

I understood that he simply wants to assign INS to "New Folder". In that case:
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: creating hot key to add new folder

Post 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 :)
One of my scripts helped you out? Please donate via Paypal

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

Re: creating hot key to add new folder

Post by admin »

Yes, also. It could be both. Only Mac can tell.

Mac
Posts: 5
Joined: 15 Feb 2013 18:59

Re: creating hot key to add new folder

Post 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
To see the attached files, you need to log into the forum.

RalphM
Posts: 2143
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: creating hot key to add new folder

Post 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!
Ralph :)
(OS: W11 26H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

Mac
Posts: 5
Joined: 15 Feb 2013 18:59

Re: creating hot key to add new folder

Post 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.
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: creating hot key to add new folder

Post 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.
One of my scripts helped you out? Please donate via Paypal

Mac
Posts: 5
Joined: 15 Feb 2013 18:59

Re: creating hot key to add new folder

Post 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!

Post Reply