Where's the list of commands?

Discuss and share scripts and script files...
Post Reply
Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Where's the list of commands?

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

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Where's the list of commands?

Post 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.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

Post 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

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

Post by Ghosty »

I fixed it with quotes around the whole name,

new "<curname>.OK", file

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Where's the list of commands?

Post 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++;
   }
   
Last edited by Stefan on 31 May 2010 09:04, edited 1 time in total.

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

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

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Where's the list of commands?

Post 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 :D
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?

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

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

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Where's the list of commands?

Post 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...
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

Post 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

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

Post by Ghosty »

Also. I tried avi+mkv and it does work...

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

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

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Where's the list of commands?

Post by Ghosty »

The problem goes away when I uncheck the advanced option -> Default Items only in Shell Context Menu

Post Reply