PDA

View Full Version : Request for custom command suggestions


bigstar
04-23-2014, 08:21 AM
If you have some suggestions on how we can improve custom commands please let me know.

Most importantly please provide an example of how the command could be used.

Thank you,
Charles DeWeese
OpenSight Software

DayCuts
04-24-2014, 12:00 AM
1. PCRE support in $replace with capturing and replacement of captured groups in newstring if rx: form is used for substring.
$replace("<string>","<substring|rx: /substring/>","<newstring>")
Rename from "Author - Title of Publication.pdf" to "Title of Publication by Author.pdf"
{
RNFR %f
RNTO $replacerx(%f, rx: /^(..*)\S\-\S(..*)(\...*)$/, \2 by \1\3)
}

2. Queue command to add selected items to the transfer queue (for use with the already present Compare and potential Select)

3. Select command possibly with &f or similar to reference the results of the last Select or Compare
Select <string/rx: pattern>, or similar

Example use: recurse and queue matching items from multiple sub-directories. I know this is a simple example that can be done with selective transfer rules, but combining recursion and grouped command with Select and $replace(&f,...) etc opens up a lot more possibilities.
{
&cd %f
List
Select <*Dr Seuss*> OR Select <rx: ..*\Sby\SDr.?Seuss..*>
Queue
CDUP
}

There are probably other things I could recall thinking of in the past but I feel they are crossing the line between a simple custom command interface and full script-ability support.

bigstar
04-24-2014, 02:17 PM
Great ideas especially the use of PCRE for find and replace.
I will need to add support for this into my PCRE library wrapper first.

I have been working on some new select commands however I have come to a slight bump in the road, doing some testing I found a couple situations where we'll need a way to select just files or dirs.

bigstar
04-26-2014, 10:56 AM
I have successfully added $replacerx()

This replace function is rx specific so the rx: prefix from the pattern must be omitted.

An example of using $replacerx() with /ren and we /enqueue the /ren operation so we can review the operation before executing it.

/enqueue /ren "%p%f" "%p$replacerx("%f", "^([0-9]+[\s][-]) (.*)\.(.*)$","\2.\3")"Input: C:\path\3938 - How to win.txt
Output: C:\path\How to win.txt

In the queue window the operation would appear as
/ren "C:\path\3938 - How to win.txt" "C:\path\How to win.txt"

Also if the pattern fails to match or the result is an empty string then the original input value returned.

I have some additional testing to do before I make these changes available.

As expected, the more testing I do the more problems I find.

bigstar
04-28-2014, 04:30 PM
I have released v5.0 build 3731 with these changes.

Below is a complete list of all commands (unless I missed some)

[<name of custom command>]
Execute a stored custom command. This can be used to create a custom command that then executes multiple commands.

[<path\to\text\file>]
Execute a custom command stored in a external text file.

/switch
Switch focus from the current active side to the opposite side.

/list <parameters>
Refreshes the file listing. the parameters are optional.

/cd <path>
Change to path in active side

/uncd
Changes back to the original path where the custom command was executed undoing any /cd's

/activate 1
Activate the left side

/activate 2
Activate the right side

/activate local
Activate the local side

/activate remote
Activate the remote side

/compare
Execute compare folder content command using current settings

/compare and hide
Execute compare folder content command and force matches to be hidden

/compare and select
Execute compare folder content command and force non-matches to be selected

/selectinvert
Invert item selection

/ren "<old name>" "<new name>"
Rename the old name to the new name

/stop
Stop the queue

/loadstr <rule set name>
Load a selective transfer rule set by name

/delay <seconds>
Delay <seconds> before continuing to the next item in the queue

/queue selected
Add current selection to the queue (standard behavior / prevents duplicate items from being added to the queue).

/queue selected true
Add current selection to the queue (special behavior / allows duplicate items).

/queue selected <modifer>
Add current selection to the queue as <modifer>. Use $replace(), $replacerx(), $lowercase(), etc to modify the target name.

/clear cache
Clear the remote cache of the active side

/clear cache all
Clear the remote cache for all sites

/selectall -f
Select all files in the active side

/selectall -d
Select all directories in the active side

/selectall
Select all items in the active side

/select -f <mask>
Clear current selection and select files matching <mask> can be a wildcard or rx: mask.

/select -d <mask>
Clear current selection and select directories matching <mask> can be a wildcard or rx: mask.

/select <mask>
Clear current selection and select items matching <mask> can be a wildcard or rx: mask.

/select -f <mask>
Preserve current selection and select files matching <mask> can be a wildcard or rx: mask.

/select -d <mask>
Preserve current selection and select directories matching <mask> can be a wildcard or rx: mask.

/select <mask>
Preserve current selection and select items matching <mask> can be a wildcard or rx: mask.

/selectclear
Clear any current item selection in the active side.

/run "<full pathname>" "<working dir>" "<command line params>"
Run a local program and wait for the program to close before continuing. each parameter must provided and quoted.

/exec "<full pathname>" "<working dir>" "<command line params>"
Execute a local program or open a file using windows default file association for the file type. each parameter must
provided and quoted.

/markedtoggle
Add or remove the current selection from the marked list.

/markedselect
Select any item that is in the marked list.

/markedclear
Clear the marked list

/markedexport
Export marked list to the clipboard

/markedimport
Import marked list from the clipboard

/enqueue <command>
Insert any command into the queue.

/delete selected
Insert a delete operation into the queue.

/transfer queue
Start the transfer queue.

&window <title>
Creates a text window with the results of the commands that follow. The title is optional.

bigstar
05-02-2014, 11:32 AM
I am thinking about adding additional switches to the /select command so that one could select based on size and age what do you think?

Right now I am experimenting with this idea and it seems to work quite well, though I am unsure if it will be added at this stage.

The switches would be something like this
-<value> for the minimum value
+<value> for the maximum range

Select based on an size range
:size-<min>+<max>It would support the following suffixes b=byte, m=megabyte, g=gigabyte

:size-10Mmeaning any file with a size of 10MB or less

:size+5M-10Mmeaning any file with a size of at least 5MB or more but equal or less than 10MB

Select based on an age range
:age-<min>+<max>It would support the following suffixes s=second, m=minute, h=hour, d=day, y=year

:age-1dmeaning any file with a modified date equal or less than 1 day from now.

:age+12hmeaning any file with a modified date equal or more than 12 hours from now.

/select -f :size-10Mselect all files with a size 10MB or less

bigstar
05-26-2014, 09:26 AM
I've come to a realization that a couple things need to be tweaked for complex scripts.

Specifically in regards to the /delete <selected|%f> and /queue <selected|%f> commands
The way it works now these commands add their queue entries to the end of the queue, this poses a problem when the operation needs to occur inline rather than later on.

Depending on the situation there is a justified need for both behaviors.

Consider the following complex script. (this is not the best example but used to illustrate the situation)


[R] /rcd /temp
[R] /selectall
[R] /delete selected
<we want the delete operation to occur here but it doesn't>
[L] /lcd /outgoing
[L] /selectall
[L] /queue selected
<instead the delete operation is added here at the end of the queue>
<queued items are added here>
In this example the /delete selected operation is added to end of the queue below /queue selected and result is not what what we intended.

However there are situations where you may want the /delete selected to occur after the transfer, for example


[R] /rcd /temp
[L] /lcd /outgoing
[L] /selectall
[L] /queue selected
[L] /delete selected
<queued items are added here>
<queued delete operation is added here>
In this case we want the /delete selected to occur after the /queue selected and with the current v5.0 beta this is exactly what happens.

Clearly we'll need to have a way of enqueuing two different types of /delete selected commands but I am not entirely sure the best way to name these commands. Also since a few people may be using these commands in v5.0 we need to make sure that we don't break things on them, or give them some other options.

Ideas? Suggestions? Please :)

bigstar
06-15-2014, 11:33 AM
New script commands as of build 3741 (v5.0 beta)

Generate a SHA1 hash of a file and display the result in the status window.
/sha1 "<path\name>"[CMD] /sha1 "D:\Temp\test128.rnd"
[RESULT] SHA1: f2d7ca10dc48f9a7c5b46ef9b6daf3dad4626c55 File: D:\Temp\test128.rnd (131.07 MB/s)

In addition to SHA1 the following hashes are also supported CRC32, MD5, SHA224, SHA256, SHA384, SHA512.
i.e. /CRC32 "D:\Temp\test128.rnd

You can also use the new hash feature to display the result inline using $SHA1("<path\name")

Write/append a line of text to a file. If the file doesn't exist then it will be created, otherwise the line is appended to the end of the existing content.
/writeln "<path\name>" <text>This can be combined with the hash command above to create a .md5 file using the MD5 hash file format

# This will create separate file named <filename>.MD5 for each of the files in your current selection.
# each MD5 file is using the standard MD5 hash file format consisting of
# <md5> <filename>
/writeln "%p%f.md5" $md5("%p%f") %f
I've added the ability to add comments to custom command scripts.
Any line that begins with # will be treated as a comment.


# This will create a SFV file named "verify.sfv" in %p
# using the standard SFV hash file format
# <filename> <crc32>
/writeln "%pverify.sfv" %f $crc32("%p%f")
In case it isn't obvious these new hash commands only work when executed in the local browser.

You can test the output of % and $ tokens

Using the current item selection display the absolute path+filename
/test %p%f $crc32("%p%f")With the file test64.rnd selected the result is
[CMD] /test D:\Temp\test64.rnd

(this is just a partial test, we could use this to actually do something more useful see below.)
Change the extension .rnd of the current item selection with .exe
/test %f $replace("$lowercase(%f)",".rnd",".exe",1)With the file test64.rnd selected the result is
[CMD] /test test64.rnd test64.exe
With the file verify.sfv selected the result is
[CMD] /test verify.sfv verify.sfv

With the current selection rename the file changing the file extension from .rnd to .exe

/ren "%p%f" "%p$replace("$lowercase(%f)",".rnd",".exe",1)"
[CMD] /ren "D:\Temp\test1.rnd" "D:\Temp\test1.exe"

.. to be continued...