Page 1 of 1
How do I delete a "non-selected" file using a script?
Posted: 05 Mar 2017 20:43
by Theo
Referring to my script
viewtopic.php?p=147152#p147152 I need to add an additional task to the script. Right now, the way that it works is that I select a file and run the script on it. The script simply copies the
<curbase> of the file and pastes it into the same directory. I end up with an empty file with no extension - perfect! The problem I can't figure out is that I would like to have the same script (which is assigned to a button) delete the original file that
has the extension (the one I selected). As it works out now, the newly created empty file ends up being selected and when the "delete" part of my script comes up, it deletes the new file, not the old. I have not included the "delete" part since it was a simple command and did not work for me,
as I needed it to.
If possible, please do not give me an outright answer. A hint or two would be ideal so that I may try and figure it out the details on my own.
Thank you.
Re: How do I delete a "non-selected" file using a script?
Posted: 05 Mar 2017 20:47
by highend
Dozens of possibilities how this could be achieved...
One way:
Store the <curitem> in a variable. Create your new file. Call the delete command with that variable name at the end of your script...
Re: How do I delete a "non-selected" file using a script?
Posted: 05 Mar 2017 20:51
by Theo
Ok, great. I'll try that out today when I get a minute or two (or a few hours LOL) and get back to you with either my success or failure story. It looks simply enough though, so I'm looking at figuring it out rather than asking for more help.
Thank you.
EDIT: Ok, I give up. Some of the files I deal with have periods, brackets, and other symbols (all Windows compatible characters). Is there a type of variable that I can use to deal with those files also or do I need to find another way? I can't do
Set $f = <curitem>, for example, because of the special characters.
I found this variable
<curitemprev> described in the help as, "
previous current (selected & focused) list item (full path)". It sounds like it's exactly what I need, but it doesn't work. It wants to delete the newly created file. Am I misunderstanding what that variable is?
Current script...
Code: Select all
new(<curbase>);
delete <curitemprev>;
Re: How do I delete a "non-selected" file using a script?
Posted: 06 Mar 2017 11:15
by highend
What have special characters to do with setting a variable?
You can put any unicode string into them
No, you're not misunderstanding what this variable is. But you didn't read the help file carefully (enough)
Code: Select all
delete [recycle=1], [confirm], [itemlist]
You see what you're doing wrong here?
Re: How do I delete a "non-selected" file using a script?
Posted: 07 Mar 2017 01:49
by Theo
You know, I tried all different variations with/without the switches and tried different variables and methods of doing it. I even read about indenting the second line and tried that with all the variations I previously tried. I think my problem was that I was so overwhelmed with the many things I tried that I should have took a step back, or perhaps started fresh, and MAYBE I would have figured it out (emphasis on "maybe").
Anyway, I'm very appreciative of all the help and time you've given to me and my problem and thanks to you and Don, I now have a working script...
Code: Select all
new(<curbase>);
delete 1, 0, <curitemprev>;
I have never consumed so much time trying to figure out something so simple.
Now I have a few more scripts to write (hopefully on my own LOL) since I know a little more about how powerful this scripting is.
Thanks you very much.