Scripting does not work as hoped, V24.10

Discuss and share scripts and script files...
Post Reply
Viper96blue
Posts: 3
Joined: 12 Mar 2023 21:36

Scripting does not work as hoped, V24.10

Post by Viper96blue »

Trying to do a simple Script to backup my Arduino files.

First problem is double clicking on my script file "CopyArduino.xys" in the XYplorer Scripts Folder does nothing, Windows does not know what file to associate this file with to run it.
I was hoping to put a link to the script on the toolbar.

Next problem is the script will not run;
copy "C:\GCB@Syn\Arduino IDE\TPSRPMBRKDisplay\TPSRPMBRKDisplay.ino|J:\GCB@Syn\Arduino IDE\TPSRPMBRKDisplay\TPSRPMBRKDisplay.ino";
copy "C:\GCB@Syn\Arduino IDE\SRTCrankSim\SRTCrankSim.ino|J:\GCB@Syn\Arduino IDE\SRTCrankSim\SRTCrankSim.ino";
open "C:\Program Files (x86)\Metapad\metapad.exe"

Next problem is after updating the script, it will not load the updated version;
copy "C:\GCB@Syn\Arduino IDE\TPSRPMBRKDisplay\TPSRPMBRKDisplay.ino|J:\GCB@Syn\Arduino IDE\TPSRPMBRKDisplay\TPSRPMBRKDisplay.ino";
copy "C:\GCB@Syn\Arduino IDE\SRTCrankSim\SRTCrankSim.ino|J:\GCB@Syn\Arduino IDE\SRTCrankSim\SRTCrankSim.ino";

Next problem is if I clear the Script Dialog box and Load Script File... it does not load the file I selected CopyArduino.xys

Note; that the last line in the file is not in the Script Dialog box - open "C:\Program Files (x86)\Metapad\metapad.exe" even though I ran Load Script File... repeatedly.
If I shutdown XYplorer and restart, same problem.

However, if I manually put - open "C:\Program Files (x86)\Metapad\metapad.exe" - into the Script Dialog box, it will run the file "metapad.exe".
Really would like to create a script file that will copy numerous files and be able to place a link on the toolbar so one click will run it. Was hoping XYplorer scripting will do that.

jupe
Posts: 2791
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Scripting does not work as hoped, V24.10

Post by jupe »

When you have multiple lines in your script, make sure your additional lines are indented by at least 1 space.

Yes dbl clicking a script in the list pane won't run it by default, you can add that ability though via:
https://www.xyplorer.com/tour.php?page=pom using an entry like "Load Script" xys>#751;

The Script Dialog is not linked to the Load Script command, Load script just executes the scripting file once, Run script allows you to test scripting commands without saving to a file.

You can add the script to the "User Button #" by adding a toolbar btn and customizing the OnClick field with a cmd like this: load "scriptname.xys"; assuming you put the script file in your Data\Scripts folder, or use the full path to the file if you didn't.

viewtopic.php?t=6560

Viper96blue
Posts: 3
Joined: 12 Mar 2023 21:36

Re: Scripting does not work as hoped, V24.10

Post by Viper96blue »

Thanks, that helped. Script now runs from button on toolbar. I also changed from "copy" to "copyto".

Viper96blue
Posts: 3
Joined: 12 Mar 2023 21:36

Re: Scripting does not work as hoped, V24.10

Post by Viper96blue »

But Scripting to copy files still had couple issues. Main was Copy Dialogs, one (XYplorer) saying copy operation then the Windows Ask If Copy dialog which I did not want and couldn't find an easy way to suppress them only for the Script operation.

Because of that, I decided to redo an old multi copy/backup program I wrote many years ago (2003) which did most of what I wanted but needed a few additions/modifications. It will now automatically copy any file in the Source directory and subdirectories that is a newer file than the matching Destination directory/subdir file. And will do it for two different destination drives, from C: to J: and then C: to M:. I tested it on a directory with 700 subdirectories and 1700 files (my Arduino collection), with all files copied previously, it only took 7 seconds for the program to test all 1700 files to see if they were newer (they were not in this instance).

And I have it on the toolbars for the two file programs that I use (XYplorer and Powerdesk).

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

Re: Scripting does not work as hoped, V24.10

Post by RalphM »

Sounds like a problem that sync (see help with scripting commands) should be able to solve on XY's side.
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

Post Reply