Several Smart Mover Tasks can use Regular Expressions (RegEx) to add more flexibility to its functionality. These include:
Copy Files: selectively copy each file based on a RegEx match of the file name, file contents or XMP contents. It is a great way to "sort" files into different folders based on those parameters where they can then be processed by other Tasks.
Search & Replace: perform RegEx search and replace on text files as they are moved from one folder to another. This enables you to change line endings, convert markup languages, remove HTML/XML tags, etc.
Delete Files: selectively delete files based on the same criteria as Copy Files.
Rename Files: rename the files based on a RegEx search pattern with a replace pattern.... a real easy way to change file extension.
Image Processing sips and IM: where you can change the name of the output file. Similar to Rename Files.
To take advantage of this powerful tool you need to have at least a basic understanding of RegEx and its syntax. Appendix A of Mover's User Guide includes a summary and some examples but it is not a tutorial or complete listing. But there are numerous web sites that can help including:
There are also some applications that will help create and test your expressions:
But let's do some common Mover examples:
Lets say I want to rename all the files in a given folder that end with ".xml" to ".txt". I would do the following:
Let's look at the "From" expression first.... skipping over the "()" for now.... The "dot" in RegEx represents any character... and when followed by the repetition character "*" means any number of any characters. The "\" means that the next character, a dot in this case, is really a dot and not "any character".... "xml" is just simply its literal self. So this "From" expression matches all the file names that end in ".xml".
The "To" expression starts with "\1". This is a subexpression that refers to the characters that were found inside the first set of "()" in the "From" expression. So in this case it is the file's name without the extension. The "\." again means an actual dot... followed by the literal "txt".
So a file called "jim.xml" becomes "jim.txt" and a file called "woodwing.xml" becomes "woodwing.txt". A file called "jim.jpg" does not match the "From" expression so it would not be renamed.
The "\1" in the "To" expression specifically refers to the first subexpression or pair of "()" found in the "From" expression. If you had multiple sets of "()" they would be referred to as "\2", "\3" and so on.
Let's say we have some files named something like "aaa-bbb.txt" and we just want to remove "-"... use the following:
Hopefully this will give you a little more basis to work from.
Keep in mind that just renaming a file and changing its extension can confuse your system and potentially Enterprise or Elvis. Just renaming a .txt file to .jpg does not make it an image.
Please sign in to leave a comment.