Page 1 of 1
Where's the list of commands?
Posted: 31 May 2010 07:03
by Ghosty
I want to do this:
echo OK >%1.ok
This will put the text "OK" into a file with the same name as the selected file with ".ok" appended to the end.
It should work the same with multiple files.
Re: Where's the list of commands?
Posted: 31 May 2010 07:49
by j_c_hallgren
Hi and welcome to the XY forums!
As far as that type of rename, the typical XY way to do it would be via "Batch Rename" under File>Rename Special with a pattern of '* OK'.
As far as list of cmds, see "help on scripting cmds" in Help.
Re: Where's the list of commands?
Posted: 31 May 2010 08:00
by Ghosty
I want this on the toolbar as a button, no submenus to navigate.
This almost works, but it doesn't put the . in the file name?!
new <curname>.OK, file
I'm working with this now but I don't understand why it wont stop stepping. When I open a script, it shows the list of lines in the script. I've toggled stepping on and off, doesn't make any difference.
set $a = <curname>.ok
msg "this is a " $a
Re: Where's the list of commands?
Posted: 31 May 2010 08:04
by Ghosty
I fixed it with quotes around the whole name,
new "<curname>.OK", file
Re: Where's the list of commands?
Posted: 31 May 2010 08:24
by Stefan
Hi Ghosty, welcome.
The dot is used for concatenation like with PHP:
"file" . "ext" == fileext
"file" . ".ext" == file.ext
The Debug dialog appears always if you use menu "Scripting > Try Script..."
no matter if "Scripting > Step Mode" is set or not. (Sometimes this disturbs me too, maybe this should be improved?)
> Where's the list of commands?
http://www.xyplorer.com/xyfc/viewtopic. ... 239#p47239
Ghosty wrote:I want to do this:
echo OK >%1.ok
This will put the text "OK" into a file with the same name as the selected file with ".ok" appended to the end.
It should work the same with multiple files.
Try this:
Code: Select all
/*
Create an new file for each selected file
with the same name but add ".OK" at the end
and put the word "OK" as content.
*/
End ("<curitem>"==""), "No file selected!"; //check if any file is selected
//get list of selected files:
$filelist = getinfo('SelectedItemsPathNames', '|');
$count = 1;
while(1)
{
//get an file from the list:
$file=gettoken($filelist,$count,"|");
if("$file"==""){break;}
//filter out files with already .OK extension:
$check = regexreplace($file, ".+(...)", "$1", 0);
// IF ($check){$check=".OK";} // always upercase --- disabled because of nonsens
//if not already .OK extension, create an new file with "OK" content:
IF ($check != ".OK")
{
//writefile(filename, data, [on_exist], [mode])
writefile($file . ".OK", "OK", n, t);
}
$count++;
}
Re: Where's the list of commands?
Posted: 31 May 2010 08:45
by Ghosty
Thanks. Looks like a good link for what I'm doing.
I saved your script to a file, selected a file I want to process, and did the "load script file" and it does nothing. I don't get it... is it bugged?
Also, when I select multiple files, I get no context menu on them unless I right click on the first one, then it thinks I have only one selected.
Did I mess up some settings?
Re: Where's the list of commands?
Posted: 31 May 2010 08:56
by Stefan
For me it works.
Note:
- if the current file already has an ".ok" extension the script skips
- if there is already an "file.ext.ok" the script skips
Oh
i have an logical bug in the case check.
Please comment out the line
IF ($check){$check=".OK";} // always upercase
by two leading //
//IF ($check){$check=".OK";} // always upercase
What do you mean by "context menu" ... is this related to this script?
Re: Where's the list of commands?
Posted: 31 May 2010 09:12
by Ghosty
Stefan wrote:For me it works.
Note:
- if the current file already has an ".ok" extension the script skips
- if there is already an "file.ext.ok" the script skips
Oh
i have an logical bug in the case check.
Please comment out the line
IF ($check){$check=".OK";} // always upercase
by two leading //
//IF ($check){$check=".OK";} // always upercase
It works now

I noticed that after editing my button in one XY window, the other one was not updated.
This also works on a button:
new "<curbase>.OK", file, "C:\Users\theuser\Documents\XYPlorer\XYScripts\ok.fill"
What do you mean by "context menu" ... is this related to this script?
I was concerned about why the script wasn't working, but now I think the context menu issue is unrelated.
I should post the context menu issue in another thread.
Re: Where's the list of commands?
Posted: 31 May 2010 09:20
by j_c_hallgren
Ghosty wrote:I should post the context menu issue in another thread.
We're not that picky here so another thread may not be needed quite yet...let's explore the issue here a bit more first...
Re: Where's the list of commands?
Posted: 31 May 2010 09:29
by Ghosty
OK.
The context menu issue only applies to selections of different types.
I DO get context when selecting one or more of these types...
avi,
m3u,
png,
pdf
I Don't get context for...
avi+m3u
png+pdf
Re: Where's the list of commands?
Posted: 31 May 2010 09:40
by Ghosty
Also. I tried avi+mkv and it does work...
Re: Where's the list of commands?
Posted: 31 May 2010 09:50
by Ghosty
These do not work no matter which one I right click on...
AVI + TXT
M3U + TXT
MKV + TXT
AVI + NFO
These do work when either selected file is right clicked...
TXT + TEXT (unkown type) does work.
TXT + NFO
PNG + JPG
AVI + MKV
With these, only the right click on the first one opens context, the second does not.
JPG + NFO
JPG + TXT
JPG + MKV
PNG + NFO
PNG + TXT
All combos work in Directory Opus.
Re: Where's the list of commands?
Posted: 31 May 2010 09:57
by Ghosty
The problem goes away when I uncheck the advanced option -> Default Items only in Shell Context Menu