How to Create Custom Commands
Previous  Top  Next

Custom commands provides an easy way to send any commands to the FTP Server, so you can communicate with the server by sending commands that are not directly supported by 3D-FTP. You can either send a one time server command or store them for later use.


Send a server command


To quickly send a custom command to the server:

1.Select Commands > Custom Commands > Send and Edit Custom Commands from the menu. This menu is also available by right clicking the remote file listing.  
2.Enter the command you want to send to the server in the Enter server command: field  
3.Click the Send button  
 
You can access previously entered commands by selecting from the drop-down list.


Create a new custom command


If you need a send a specific server command often, or you want to send a sequence of commands, it makes sense to save it for later reuse.

1.Select the Commands > Custom Commands > Send and Edit Custom Commands from the menu. This menu is also available by right clicking the remote file listing.  
2.Click the New... button  
3.Enter the custom command identifier to the Custom Command Label field. You can add a character to make the next letter a short-cut key (shown underlined in the menu)  
4.Type the commands to the List of Server Commands text field. You can enter multiple commands by separating them with linefeed (=press Enter). Commands are sent to the server in the sequence they appear in this field, and they can contain one or more macros (see more about macros below).  
5.Click the OK button  
 
Now the new custom command is available for use in the Commands > Custom Commands menu.


Refresh Remote File Listing Check Box


By selecting this option, you can automatically command 3D-FTP to refresh the remote file listing after sending custom commands to the server. This is handy if custom command modifies the remote files, so that the remote file listing is reread from the server to keep the file details up-to-date.


Macros in Custom Commands


Saved custom commands can contain macros that are expanded when custom command is send to server. These macros are:


Macro
Replaced with
Example
%fn
FileName. Replaced with currently selected filename
Autoexec.bat
%fp
Filename with Path
/pub/bin/Autoexec.bat
%fs
File Size
54321
%fa
File Attributes
-rwrwrw
%fd[Format]
File Date and Time. See more about format below
12/31/2008 09:45:59
%p[Prompt]
Show user an input box and prompt user to enter a value. Entered value replaces this macro.

%log
If present in the beginning of the line, this line is show in the log window and not sent to server






If any of the file-related macros are present in the custom command (%fn, %fp, %fs, %fa, andfd), one or more files must be selected in the remote file listing when custom command is selected. If multiple files are selected, the command sequence is repeated once for each file.

In the examples below, two files /pub/FileA.txt and /pub/FileB.txt are selected in the remote file list when the command is selected.


Examples


Example Cmd with Macros 1: Search for files

Custom command sequence:

SITE INDEX %p[Search for text:]

Output when executed:

Macro prompts user "Search for text:". User enters *.cgi and clicks OK
Macro sends
SITE INDEX *.cgi


Example Cmd with Macros 2: Change file attributes

Custom command sequence:

SITE CHMOD %p[Enter new attributes for the file %fn] %fn

Output when executed:

Macro prompts user "Enter new attributes for the file FileA.txt". User enters 771 and clicks OK
Macro sends
SITE CHMOD 771 FileA.txt
Macro prompts user "Enter new attributes for the file Autoexec.bat". User enters 771 and clicks OK
Macro sends
SITE CHMOD 771 Autoexec.bat


Example Cmd with Macros 3: Show selected file details

Custom command, list of commands:

%log =========================
%log Filename: %fn
%log Filename with path: %fp
%log File Size: %fs
%log File Attributes: %fa
%log File Date & time: %fs[MM/DD/YY hh:nn:ss]


This macro sends nothing to the server, it only displays text in the log pane:

=========================
Filename: FileA.txt
Filename with path: /pub/FileA.txt
File Size: 12345
File Attributes: -rwrwrw
File Date & time: 06/06/07 12:00:31

=========================
Filename: FileB.txt
Filename with path: /pub/FileB.txt
File Size: 543321
File Attributes: -rwrwrw
File Date & time: 12/31/07 15:10:00



Example Cmd with Macros 4: Rename file

Custom command sequence:

%log === RENAME FILE %fn ==============
RNFR %fn
RNTO %p[Enter new name for file %fn]


Output when executed:

=== RENAME FILE FileA.txt ==============
RNFR FileA.txt
Macro prompts user "Enter new name for file FileA.txt". User enters NewA.txt and clicks OK
RNTO NewA.txt
=== RENAME FILE FileB.txt ==============
RNFR FileA.txt

Macro prompts user "Enter new name for file FileB.txt". User enters NewB.txt and clicks OK
RNTO NewB.txt


%fd Macro Format parameter



The following table identifies characters you can use to create date/time formats:
   
Character
Description
(:)
Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
(/)
Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
c
Display the date as ddddd and display the time as ttttt, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion.
d
Display the day as a number without a leading zero (1 – 31).   
dd
Display the day as a number with a leading zero (01 – 31).
ddd
Display the day as an abbreviation (Sun – Sat).
dddd
Display the day as a full name (Sunday – Saturday).
ddddd
Display the date as a complete date (including day, month, and year),formatted according to your system's short date format setting. For Microsoft Windows, the default short date format is m/d/yy.
dddddd
Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. For Microsoft Windows, the default long date format is mmmm dd, yyyy.
w
Display the day of the week as a number (1 for Sunday through 7 for Saturday).
ww
Display the week of the year as a number (1 – 54).
m
Display the month as a number without a leading zero (1 – 12). If m immediately follows h or hh, the minute rather than the month is displayed.
mm
Display the month as a number with a leading zero (01 – 12). If m immediately follows h or hh, the minute rather than the month is displayed.
mmm
Display the month as an abbreviation (Jan – Dec).
mmmm
Display the month as a full month name (January – December).
q
Display the quarter of the year as a number (1 – 4).
y
Display the day of the year as a number (1 – 366).
yy
Display the year as a 2-digit number (00 – 99).
yyyy
Display the year as a 4-digit number (100 – 9999).
h
Display the hour as a number without leading zeros (0 – 23).
hh
Display the hour as a number with leading zeros (00 – 23).
n
Display the minute as a number without leading zeros (0 – 59).
nn
Display the minute as a number with leading zeros (00 – 59).
s
Display the second as a number without leading zeros (0 – 59).
ss
Display the second as a number with leading zeros (00 – 59).
t t t t t  
Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. For Microsoft Windows, the default time format is h:mm:ss.
AM/PM
Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.
am/pm
Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M.
A/P
Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M.
a/p
Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M.
AMPM
Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. For Microsoft Windows, the default format is AM/PM.

      

Sample
Output
%fd[m/d/yy]
1/31/02
%fd[d mmmm yyyy, hh:mm]
31 January 2008, 23:59
%fd[yyyy-mm-dd]
2008-01-31