WORKINGDIR        Change local default (working) folder

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

WORKINGDIR        Change local default (working) folder

Syntax:

WORKINGDIR

[ folder name ]

Alt Syntax:

CHGDIR

[ folder name ]

 

CD

[ folder name ]

Arguments:

[ path name ]

A variable or string to specify the path name of Robo-FTPs default folder.

Options:

/create

Create the destination folder if it does not yet exist.

 

/verify=x

Verify permissions for selected working directory; options are /verify="read" which returns an error if Robo-FTP does not have read permission on the specified directory; /verify="write" which returns an error if Robo-FTP does not have write permission on the specified directory.

 

/user=x

Username to use when connecting to a network share directory

 

/pw=x

Password to use when connecting to a network share directory

 

 

This script command sets the default local folder for all file-oriented script commands. If a file name without a full path is used in any script command then Robo-FTP assumes the file is located in the current working folder.

 

Calling this command without the [ path name ] argument causes the path of the current working folder to be echoed to the console window.

 

Robo-FTP always has a current working folder on the local PC. Robo-FTP only has a current remote folder while actually connected to a remote site. Use the FTPCD script command to set the current directory on a remote site.

 

The current working folder is always maintained in the %currentlocaldir variable.

 

Consider the following example.

 

;; read record in "c:\Program Files\Robo-FTP X.X\example.txt"

WORKINGDIR "c:\Program Files\Robo-FTP X.X"

READFILE "example.txt" first_record

 

If a partial path is specified, it and the previous working folder are used to define the new working folder.

 

;; current working folder is "c:\Program Files\Robo-FTP X.X"

WORKINGDIR "test"

;; new working folder is now "c:\Program Files\Robo-FTP X.X\test"

 

If two periods “..” are specified, the new working folder is set one folder above the previous working folder.

 

;; current working folder is "c:\Program Files\Robo-FTP X.X"

WORKINGDIR ".."

;; new working folder is now "c:\Program Files"

 

Important

This command overrides the Working Directory folder selected on the Files menu in the Robo-FTP Configurator.
 

The directory change made by WORKINGDIR is global within the Robo-FTP script environment. If WORKINGDIR is called in a function or a called script, we recommend that the current working folder be saved on entry and restored on exit to prevent unintended consequences. See the help topic for the %currentlocaldir internal variable for an example.

 

The directory change made by WORKINGDIR will be overwritten if you subsequently use FTPLOGON to connect to a Managed Site that specifies a different Initial Working Directory.

 

 

The [ path name ] argument accepts the built-in internal variables and also user-defined variables.

 

;; set working folder to Robo-FTP installation folder:

WORKINGDIR %installdir

;; the current instance of Robo-FTP can definitely write to this folder:

WORKINGDIR %programdatadir

;; a user-defined variable with a dynamic value for the folder name:

SET source = "c:\outbound\" + %date

WORKINGDIR source

 

Suppose your script may be executed an unknown number of times each day and the files that it processes are in a folder named with today's date. The /create option will attempt to create the destination folder if it does not already exist. This way, you don't need to add script logic to handle the condition that today's folder does not yet exist.

 

SET source = "c:\outbound\" + %date

WORKINGDIR source /create

 

You can also use the WORKINGDIR command to connect directly to a password-protected Windows Share. Consider the following example:

 

 WORKINGDIR "\\my-host\share-name\subdir" /user=myusername /pw=mypassword

 

Related command(s): FTPCD, FTPPWD, MAKEDIR, DELDIR, LISTDIR

See also: %currentlocaldir, %currentsitedir