"Move to Server" Command Script (Updated from Button Script)

This is a new version of my previous button script:

The new version below changes it to a command script and was rewritten in JavaScript. The options are now configured using the Preferences/Toolbars/Scripts/Move to Server options.

MoveToServer - a command to copy or move selected files from the source lister to various predefined locations (default root directory is 'D:"). I use it on program installation and update files, moving them to specific folders on my server for storage.

Features:

  • Testing mode so you can see what the final destination and file name will be for each selected file (open the Utility Panel and select 'Other Logs' to see the output).
  • Copy or move selected files with a single button click
  • Define a root location for your files.
  • Define different folders at the root location, depending on file name
  • Optionally determine the version number of the file and add it to the file name if required.

Usage:

Select files (not folders) in the source directory and run the command MoveToServer from a button.

Installation & Configuration:

  1. Download Move to Server.js.txt (19.1 KB)

  2. Drag the downloaded file to the list under Preferences / Toolbars / Scripts.

  3. From the same place in Preferences, select the new script and click its name to open its configuration dialog.

Configuration options:

The 'Root' option refers to the root location for your destination folders. It must already exist. Default is D:\

The 'FileStem' stem/folder pairs must be completed as follows:

cal:Calibre
ccs:CCleaner
DOp:DOpus\V11
etc.

You can paste a list of stem/folder pairs into the editor window or type them in manually (one per line). Please note that these folders must already exist in the destination location ('Root'). This must done before running the script for the first time.

If a 'FileStem' is not configured for a particular file, then the user will be prompted to select (or create) a folder in the base location. If the dialogue is cancelled, the file will be copied/moved to the base location ('Root').

The 'keyLength' option refers to the 1st 3 characters (stem) of the selected file names. These should be unique to each file. If you need to use more (or less) to achieve a unique 'stem' then change this value.

The 'FindVersion' option decides whether the script will look for a valid Version Number in either the file name or within the file's properties. If found in the file name, then it is not modified. If found in the file's properties but not the file name, then it is added to the file name with a leading underscore (_). If no valid number is found, the user will be prompted to enter the version number. If the dialogue is cancelled, the file name will be not be modified. Please note that this is not infallible and may return incorrect version numbers. the script looks for a number or numbers followed by a dot. Any match equal to or less than 3 characters will be ignored.

The other options are fairly self explanatory but note that if 'Testing' is set to 'True' then 'ConfirmDelete' and 'DeleteFiles' are ignored as they are bypassed in the script.

Once configured, the 'MoveToServer' command should be available to use in a buttons, menus, etc.

Any problems, please ask. Feel free to offer any suggestions for improvement.