Go Back   FlashFXP Forums > >

Custom Commands Download, share, or get help creating your own.

Closed Thread
 
Thread Tools Display Modes
Old 04-23-2014, 08:21 AM   #1
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Lightbulb Request for custom command suggestions

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
bigstar is offline  
Old 04-24-2014, 12:00 AM   #2
DayCuts
Senior Member
FlashFXP Beta Tester
 
Join Date: Dec 2003
Posts: 421
Default

1. PCRE support in $replace with capturing and replacement of captured groups in newstring if rx: form is used for substring.
Code:
$replace("<string>","<substring|rx: /substring/>","<newstring>")
Rename from "Author - Title of Publication.pdf" to "Title of Publication by Author.pdf"
Code:
{
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
Code:
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.
Code:
{
&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.
DayCuts is offline  
Old 04-24-2014, 02:17 PM   #3
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Default

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 is offline  
Old 04-26-2014, 10:56 AM   #4
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Default

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.

Code:
/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
Code:
/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 is offline  
Old 04-28-2014, 04:30 PM   #5
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Default

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 is offline  
Old 05-02-2014, 11:32 AM   #6
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Default

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
Code:
:size-<min>+<max>
It would support the following suffixes b=byte, m=megabyte, g=gigabyte

Code:
:size-10M
meaning any file with a size of 10MB or less

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

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

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

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

Code:
 /select -f :size-10M
select all files with a size 10MB or less
bigstar is offline  
Old 05-26-2014, 09:26 AM   #7
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Default

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)

Code:
[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

Code:
[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

Last edited by bigstar; 05-26-2014 at 10:00 AM.
bigstar is offline  
Old 06-15-2014, 11:33 AM   #8
bigstar
FlashFXP Developer
FlashFXP Administrator
ioFTPD Beta Tester
 
bigstar's Avatar
 
Join Date: Oct 2001
Posts: 8,012
Default

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.
Code:
/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.
Code:
/writeln "<path\name>" <text>
This can be combined with the hash command above to create a .md5 file using the MD5 hash file format
Code:
# 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.

Code:
# 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
Code:
/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
Code:
/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
Code:
/ren "%p%f" "%p$replace("$lowercase(%f)",".rnd",".exe",1)"
[CMD] /ren "D:\Temp\test1.rnd" "D:\Temp\test1.exe"

.. to be continued...

Last edited by bigstar; 06-15-2014 at 11:46 AM.
bigstar is offline  
Closed Thread

Tags
command, custom, opensight, provide, suggestions


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:13 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)