Create empty copy

Discuss and share scripts and script files...
Post Reply
admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Create empty copy

Post by admin »

Just a quickie that I happened to need a lot recently. I creates an empty copy of the currently selected item in the same location, and with a similar name:

Code: Select all

// create empty copy of current item
  if (exists(<curitem>) == 2) {
    new("<curname>", "dir", , "r");
  } else {
    new("<curname>", "file", , "r");
  }
PS: hmmm, looking at that code now I think we could use a variable <curtype> to return drive, folder/dir, or file. :)

Theo
Posts: 6
Joined: 05 Mar 2017 04:33

Re: Create empty copy

Post by Theo »

This appears to be exactly what I'm looking for, but I get the following error when using it...

Code: Select all

1    C:\Program Files (x86)\XYplorer v15\Data\Scripts\create_empty_file.xys

     Overflow
1    0 / 0
I copied the script to a text file and gave it an xys extension. I then put it in the Scripts folder. I made a Custom Toolbar Button with C:\Program Files (x86)\XYplorer v15\Data\Scripts\create_empty_file.xys in the On left click: line.

Am I missing something?
____________________________________________________________________________
Give a man a script and he scripts one way. Teach a man to script and he scripts all ways.

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

Re: Create empty copy

Post by admin »

The "On left click:" expects a script, not the path of a script file.

Either
- paste the script directly into the field (use the Edit... button right of the field)

Or
- load your script file by pasting this into the field:

Code: Select all

load "C:\Program Files (x86)\XYplorer v15\Data\Scripts\create_empty_file.xys";

Theo
Posts: 6
Joined: 05 Mar 2017 04:33

Re: Create empty copy

Post by Theo »

Thank you for the quick reply. I actually figured it out on my own after quite a few hours of reading the help file and learning many other things about XYplorer that I didn't know it could do. I wish I could have deleted my post to save you the time replying to me. Sorry about that.

I also found a much easier way to do what I needed to do...

Code: Select all

new(<curbase>);
It was THAT simple!

My entry on the Left click portion of the button...

Code: Select all

load "create_empty_file"
I really love the scripting capability of XYplorer and plan to learn and do more with it now that I found the list of commands and how to use them LOL.

I have another question related to my use of the script, but I'll open a new topic since it's not related to this one.

Thanks again, for the help.
____________________________________________________________________________
Give a man a script and he scripts one way. Teach a man to script and he scripts all ways.

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

Re: Create empty copy

Post by admin »

Code: Select all

new(<curbase>);
Well, this drops the extension, and it does not work for folders, right? But if you are happy with it, okay. :)

And welcome to the club!
Don

Theo
Posts: 6
Joined: 05 Mar 2017 04:33

Re: Create empty copy

Post by Theo »

I haven't tried it with folders - I only need it for files.

Thanks for all the help. This forum is one of the most helpful I have seen anywhere, and quick to reply also. Another thing I like is that you, the developer, is involved. Try using the Logitech and Kaspersky (to some extent) forums for help. Company people are nowhere to be found. I know a lot of users are very knowledgeable, but it's a plus to see the developer involved too. You truly earn and deserve the money to make.
____________________________________________________________________________
Give a man a script and he scripts one way. Teach a man to script and he scripts all ways.

Post Reply