Fledge is a language/shell for processing files (mainly text and image files). A few examples will hopefully explain it better:
with *.text
split on /==%==/ to page-%%%.text starting with 1
replace /==%==//
trim
Or:
with image*.jpg where width < 600
print name, imagesize
rotate 90
resize 150w
Or:
with **/*.png
convert to jpg
And so on. Select files, then run one or more actions on that selection.
The fl
script will get installed to /usr/local/bin
. The installer will automatically create a ~/.fledge
directory, which you can delete if you don't want it.
- Download the package.
sudo python setup.py install
sudo pip install cmd2
- Install libjpeg if you don't already have it installed:
curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
tar -xvzf jpegsrc.v8c.tar.gz
cd jpeg-8c
./configure
make
sudo make install
- Install PIL.
- On OS X, first install XQuartz.
- Download the source kit
tar -xvzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
- OS X: Edit
setup.py
and at line 151 (afteradd_directory(library_dirs, "/usr/local/lib")
) add the following two lines:add_directory(library_dirs, "/opt/X11/lib")
add_directory(include_dirs, "/opt/X11/include")
python setup.py build
sudo python setup.py install
You can use Fledge as an interactive shell or to execute .fledge
scripts.
$ fl
fl> with *.text
fl> print name
fl> help
Or:
$ fl myscript.fledge
More help is coming, but within the Fledge shell you can type help
to get an overview. You can also type help [action]
for help about a specific action.
alias
: Set an alias for an action or a pathaliases
: List aliasesappend
: Append text to the selected text filesconvert
: Convert the selected files to another formatcopy
: Copy the selected files to a new directorydeselect
: Deselect files from the current selectionflip
: Flip the selected image filesmove
: Move the selected files to a new directoryprepend
: Prepend text to the selected text filesprint
: Print attributes (name, size, etc.) about the selected filesrename
: Rename the selected files sequentiallyreplace
: Find-and-replace on the selected text files using regular expressionsresize
: Resize the selected image filesrotate
: Rotate the selected image filesselect
: Add files to the current selectionsplit
: Split the selected text files into multiple files based on a regular expressiontrim
: Trim whitespace off the beginning and end of the selected text fileswith
: Start a new selection
User customizations live in the ~/.fledge
directory. If you have put Fledge commands in ~/.fledge/fledgerc
, they will be run before anything else (mostly useful for setting up commonly used aliases).
Custom actions can be added to the ~/.fledge/actions
directory, and you can look at the built-in actions to see how they're constructed. (Custom action files look exactly the same.)