This is a help file for the Mac Menu in Alpha. This file should be located in the Help subfolder of Alpha's folder to show up automatically in the Help menu when Alpha is loaded.
Mac Menu for Alpha allows you to achieve all kinds of files manipulations from Alpha and to interact with the MacOS file system with maximum flexibility.
You can act upon selections of files taken out of a folder or a hierarchy of folders and subfolders : the selection is made using a regular expression (regexp) and setting various additional conditions. You have thus full and extended control on which files you want to manipulate.
Actions executed on the selected files are : copying, moving, renaming, duplicating, trashing/untrashing, locking or unlocking, making aliases, selecting or unselecting, listing, changing creator type.
You can also get complete system information about all kinds of elements such as files, folders, disks, processes etc. and set new values for certain properties (change a type, a creator, a modification date, sharing status etc.). Commands are also provided for basic Finder's tasks : emptying the trash, restarting the computer etc.
All the commands are available from a menu called Mac Menu but the package also implements a 'shell' to execute all these functions from a command line. For instance, just type 'empty' at the prompt of Mac Shell to empty the trash. A very simple syntax is provided to write commands and to navigate in the MacOS files system.
All these actions are executed without leaving the Alpha editor. The package is almost exclusively based on Apple Events sent to the system.
See the tutorial file and read more information below for a complete description of all the items available in Mac Menu.
The simplest way of installing the package is to use the automatic installation facility. Just double-click on the "OPEN TO INSTALL" file. Opening this file tells Alpha that a new package has to be installed : the procedure is automatic. Alpha knows where to store the different elements of your 'Mac Menu' package.
If you prefer a manual installation, take the following steps :
Have a look at the Mac Menu preferences in the "Packages" submenu of the "Config" menu. You can set various flags there. More explanations below.
Suppose you have a folder containing all the pages of a Web site and you want a list of the image files having extension gif or jpeg. In the "List Files" dialog window, specify the folder and click on the "Predef Exts" button. In the new window check gif and jpeg and press OK. This brings back to the previous window in which the Files Filter is now set like this :
.*\.(jpeg|gif)Click OK and you get the list you wanted. You could have specified "In all Subfolders" in the "process" popup menu to get a list including files in the nested subfolders.
Suppose now you want to send to another folder a copy of the files taken out of this structure whose names meet the following requirements :
[AP].*_XY\.html?Then click on the "Add conditions" button and in the new window, set the last two contitions like so :
Modification date after 2000-12-25 Size greater than 128kleaving the other fields blank. Clicking on "Apply" brings back to the previous dialog in which you set the paths of the source and the target folders. In the "Process" popup menu, choose "in all Subfolders". Now click on "Copy" and there you go. The copy sent to the target folder will reproduce exactly the same hierarchy of folders and subfolders but will contain only the files corresponding to the required scheme.
Now suppose you want to rename the selected files. You want the new name to be like this :
[AP](.*)_XY\.html?The replacement string will then be :
Q\1\.oldTo have uppercase letters, click on the "Add options" button. In the new window, click on the "Casing" checkbox and choose UPPERCASE in the popup menu. Click "Apply" then click "Rename". That's all there is to it.
Almost all the dialog windows in which you specify the options and conditions related to some kind of file manipulation share common elements.
The top part of the dialog is an edit field in which you write a regular expression describing the naming scheme of the files you want to act upon. It is very important to note that it obeys the regular expressions syntax and not the so-called 'globbing syntax' used in some Tcl commands. For more info about the regular expressions, read the "Regular Expressions" file in the Help Menu. Regular expressions are a very powerful syntax designed to describe abstractly almost any kind of strings.
The top part of the dialog windows also contains two check boxes called "case sensitive" and "negate filter" : check or uncheck them as you want. If the "negate filter" checkbox is checked, Mac Menu will search for files which do NOT correspond to the files filter regular expression. If the "case sensitive" checkbox is unchecked, Mac Menu will not take casing into account : uppercase and lowercase letters will be considered equivalent. The "Add Conditions" button calls a new dialog window in which you can specify additional options concerning the MacOS type or creator of the files, the date of creation or modification and the size (in kbytes). Dates are indicated in the ISO format (yyyy-mm-dd).
NB: the "negate filter" flag, if set, negates the filtering regular expression but NOT the additional conditions. They are... additional.
A pop-up menu lets you specifiy whether an action should be taken on all the files corresponding to the filter in the current directory, or should be extended to the subfolders down to a specified level as well or even to all subfolders, subsubfolders etc.
Almost all the dialog windows contain an edit field to specify the source folder : the folder in which to look for files or the folder at the top of the hierarchy if subfolders are concerned too. You can write the complete path of the source folder in the edit field or use the "Set" button to browse through the file system with a standard dialog.
When relevant (to copy or move files), an additional edit field lets you choose a target folder. If files are taken out of a hierarchy, the hierarchy will be transported to the target folder : if corresponding subfolders do not exist in the target folder, they will be created automatically. If the target folder itself does not exist, it is created too so you can specify the name of a non existing folder in the edit field. Use the "Set" button to choose an existing folder.
All the dialog windows have at least two buttons at the bottom: one to execute the desired action, one to cancel.
The "Rename Files" dialog window contains a specific field to set the renaming scheme : it uses the substitution syntax of regular expressions. So you can use the special substitution symbols : & to designate the entire match, \1, \2 etc. to designate sub-expressions corresponding to pairs of parentheses in the files filtering regular expression. A button called "Add Options" brings up a new dialog window in which you can choose more options. They concern casing, incremental numbering and truncating. Tey have the following meaning :
The "Trash Files" dialog has no target folder field : the target is the trash. The "Untrash Files" dialog is different from the others and proposes two options : "last trashed" or "all". In the first case, will be untrashed (i-e sent back to their original position in the files system) only the files most recently trashed from the "Trash Files" item in the Mac Menu. This is a sort of 'undo' facility if you have accidentally trashed files or have a remorse. With the "all" option, all the files currently in the trash will be untrashed.
The "Change Creator" dialog has an additional button called "Other" : if a creator type is not in the popup menu, you can specify another one. This button brings up a new dialog with an edit field to enter the new creator type (four chars maximum). If you do not know the creator type corresponding to an application, use the "Same as" button and indicate the application or any document created with this application. The "Apply" button selects the new type and brings back the "Change Creator" dialog ; the "Add&Apply" button has the same effect but additionally records the new type in the popup menu to make it available for future use (the list is reset though each time Alpha is relaunched : to make an addition permanent use the Mac Menu Preferences. See section below about preferences).
The "Predef Exts" button is a facility to specify files with certain predefined extensions. It brings up a new dialog with a certain number of checkboxes : select the extensions you're interested in. The corresponding files filter regular expression will be built automatically in the main dialog window. If an extension is not mentioned in the "Predef Exts" dialog window, you have two possibilities :
The information windows display information about all kinds of items : files, folders, volumes, applications, processes or basic hardware. They almost all have a "Dismiss", a "Get Text". The File Infos dialog also has a "Set" button. With the "Dismiss" button, you simply quit the dialog. The "Get Text" button sends the collected information to a separate text window. The "Set" button allows you to set some properties : the corresponding fields are editable (an edit field for a variable or a checkbox for a flag). You validate your modifications with the "Set" button. Note that if your file is locked the modifications are not appliable : you must first unlock it. Be aware of what you are doing : changing low level properties is potentially dangerous. Don't play with the system files. In the case of a shared volume or folder, and if file sharing is on on the system, there is an additional "Sharing" button which gets and displays the complete sharing information about the item.
Here is the list of all the menu items of the Mac Menu with explanations. Certain items are obtained if you hold the Option Key down while opening the menu.
When holding the option key down :
When holding the option key down :
When holding the option key down :
When holding the option key down :
The Mac shell provides a command line facility analogous to the Tcl shell ('cmd-y') or the Toolsever shell ('ctrl-cmd-y') already available in Alpha. You can open it with the "Mac Shell" menu item or with the 'opt-cmd-y' key combination. This section lists all the commands available in the Mac Shell.
The main commands are 'help', 'files' and 'infos'. There are also commands which allow you to navigate in the MacOS files system : 'pwd', 'cd', 'ls', 'ld'. Additionally you have a few utility commands : 'empty', 'eject', 'restart', 'shutdown' which behave like the corresponding menu items. Please see the tutorial (choose "Mac Menu Tutorial" in the "Get Info" submenu) for real life examples.
Certain options are not handled from the command line though : if you want to specify additional conditions (as explained above) you should rather use the dialog windows.
If a command is unknow to Mac Shell, it will try to evaluate it as a Tcl instruction. This means that you can use Mac shell as a Tcl shell.
The 'help' command can be used alone or with one of the following subcommands :
help | to have a list of all available commands |
help options | to have a list of all available options and flags |
help more | to open a file with complete syntax |
help bindings | to display key bindings |
help tutorial | to open the tutorial |
help version | to get macMenu's version number |
The 'files' command is used with a subcommand to specify the type of action which is to be executed and flags to specify the conditions and options.
Here is the signification of the various options. Some of them are required, the others have default values and can be omitted if not necessary.
-f "filter" | filtering regular expr | default '.*' |
-s "folder" | source folder | default current folder (set with 'cd') |
-l "level" | nesting level (0, 1,... or all) | default 0 |
-i "flag" | case sensitive? | default 0 |
-n "flag" | negate? | default 0 |
-t "folder" | target folder | no default |
-t <kind> | target eol in transtype | default mac |
-t "type" | file's type | no default |
-c "type" | file's creator | no default |
-o "flag" | force overwrite? | default : see prefs |
-o <kind> | original eol in transtype | default unix |
-r "replace" | regsub expr for renaming | default & |
-all | all files (equivalent to '-f .*') | no value. Standalone option. |
-k "flag" | casing : u, l, w, f | default : not set |
-d "flag" | numbering : 0/1 | default : not set |
-b <mcskl> | sort by | no default |
-x "m[.n]" | truncate | default : not set |
Note that the -c option is interpreted differently with the "files change" command than with the other "files" command : in the first case, it is the required option which tells which new creator should be assigned to the selected files. In the second case, it is an optional argument telling that only the files with the type declared by -c should be selected to perform the action.
Similarly the -t option is interpreted differently with the "files change" command than with the other "files" command : in the first case, it is the required option which tells which new type should be assigned to the selected files. Used with "files transtype", the -t flag designates the target kind of file (mac, unix or win). Otherwise, it is the argument to indicate the target folder in a move, copy or alias action.
The -b flag (b stands for 'by') is used only by "files list" and allows you to specifiy a sorting option. The option is specified by one of the letters m, c, s, k, l which correspond respectively to sorting by "Modification date", "Creation date", "Size", "Kind", "Labels".
It is essential that the filtering regular expression be enclosed in brackets if some characters are escaped. The brackets protect the escaped characters from being iterpreted by the Tcl interpreter before the regular expressions interpreter. For instance, to designate all files ending with a dot followed by one single number you want to use the following expression:
.*\.\dso you should write on the command line
-f {.*\.\d}If you do not enclose the regular expression in brackets, you must escape the characters twice i-e with a double backslash like this :
-f .*\\.\\dor
-f ".*\\.\\d"This remark concerns exclusively the regular expressions used on the command line : there is no need of brackets when you use the menu items and dialog windows.
If the -d flag is on (-d 1) the numbering will be done. There is no way to set the numbering options from the command line. The last used settings will be applied.
Here is the list of the various subcommands you can append to the 'files' command together with the options they accept:
cmd | subcmds | options |
files | copy | Required -t |
Optional -f -s -l -i -n -all | ||
files | move | ditto |
files | rename | Optional -f -s -l -i -n -c -r -all |
files | transtype | Optional -f -s -l -i -n -o -t -all |
files | list | Optional -f -s -l -i -n -b -all |
files | duplicate | Optional -f -s -l -i -n -all |
files | trash | ditto |
files | lock | ditto |
files | unlock | ditto |
files | alias | ditto |
files | change | Required -c and/or -t |
Optional -f -s -l -i -n -all | ||
files | select | Optional -f -s -i -n -all |
files | unselect | ditto |
files | unalias | Optional -f -l -all |
files | untrash | Optional -all |
The 'infos' command is used with a subcommand to specify the item about which information is required. Its syntax is :
infos file "path" |
infos folder "path" |
infos volume "path" |
infos appl "path" |
infos process "processname" |
infos hardware |
Here are the commands which help you setting easily the current folder :
empty | to empty the trash |
eject | to eject a mounted removable volume |
restart | to restart the computer |
shutdown | to shutdown the computer |
As with any Alpha shell, you can move through commands history with the 'up' and 'down' arrow keys while holding the 'control key' down. If you option-click in the title bar of the Mac shell, you also have a list of the last twenty command lines and you can select any of them which will be inserted in the shell.
The proc macsh::mycmd can take parameters and arguments depending on what syntax you want for your command (subcommands, additional arguments, options etc.). Please read different examples in the file macMenuShell.tcl.
All your commands can be stored in a file. This file should start with the following instruction :
namespace eval macsh {}The easiest solution is to locate this file in the MacMenu folder and to rebuild the Tcl indices to register your procs in Alpha.
There is a completion mechanism bound to the tabulation key (exactly like in most Unix shells).
Type the first letters of a command or of a file's or folder's name and hit the TAB key : the procedure will try to complete, looking either for a command name or for the relative or absolute path of a file or a folder. If there are several possible completions, a pick list is displayed. Note that :
The "Get Info" submenu allows you to get (and set) information about various kinds of elements : file, folder, volume, application, running process and the computer itself. The results are displayed in a dialog window.
All these information windows have a button called "Get Text" to edit the results in a separate text window.
When appropriate, if a specific piece of information has a value which can be set or modified, it is edited in an editable field or with a checkbox so that you can change its value. Use the "Set" button to validate changes.
The search of information can be slow on... slow machines. Note that the information about hardware will be sought by the package only the first time and recorded since it is not likely to change during a session.
Here is a list of the properties you can find in the info windows (not all properties apply to all items of course) :
Owner | Logical size | Modification date |
Locked | Version info | Logical page size |
Shared | Creation date | Process partition |
Comment | Launched from | Largest free block |
Creator | Physical size | Minimum memory size |
Version | Remote events | Owner's privileges |
Capacity | User RAM size | Protected from move |
ROM size | Stationery pad | System architecture |
RAM size | Is share point | Low memory area size |
Ejectable | System version | Allocated memory size |
Boot disk | Virtual memory | Everyone's privilege |
CPU family | Bus clock speed | Scripting terminology |
Free bytes | Hardware vendor | Open Firmware present |
Scriptable | Software vendor | Processor clock speed |
Access path | Group privileges | Suggested memory size |
There are a few easy to remember key bindings 'a la emacs'. Press 'ctrl-z', release, then hit one of the following letters :
a | to make aliases |
b | to show this bindings info window |
c | to copy files |
d | to duplicate files |
e | to empty the trash |
f | to free (unlock) locked files |
g | to change files creator |
h | to open Mac shell |
j | to eject a disk |
k | to lock files |
l | to list files |
m | to move files |
n | to rename files |
p | to open the clipboard in the Finder |
r | to remove aliases |
s | to select files |
t | to send files to the trash |
u | to unselect files |
x | to exchange end of lines (transtype) |
y | to change files type |
z | to untrash files (z like undo) |
You can also use 'opt-cmd-y' to open the Mac Shell (same as 'ctrl-z h'). Use the tabulation key to trigger the completion mechanism in Mac Shell (see above).
The "Mac Menu Prefs..." item in the "Packages" submenu of the "Config" menu allows you to set a few general options :
Goto the Alpha utilities page :
http://webperso.easyconnect.fr/berdesg/alpha.html
Copyright Bernard Desgraupes, 2001 All rights reserved. This software is free software distributed under the terms of the new BSD license : Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: