Using regular expressions in our Sync feature, you can specify rules in the Folder+ field to include specific folders and file types in the folder. See the 2 tables below for some example scenarios that you can use these expressions:
Character | Meaning | Example |
* | Match zero, one or more of the previous | Ah* matches “Ahhhhh” or “A” |
? | Match zero or one of the previous | Ah? matches “Al” or “Ah” |
+ | Match one or more of the previous | Ah+ matches “Ah” or “Ahhh” but not “A” |
\ | Used to escape a special character | Hungry\? matches “Hungry?” |
. | Wildcard character, matches any character | do.* matches “dog”, “door”, “dot”, etc. |
( ) | Group characters | See example for | |
[ ] | Matches a range of characters | [cbf]ar matches “car”, “bar”, or “far”
[0-9]+ matches any positive integer [a-zA-Z] matches ascii letters a-z (uppercase and lower case) [^0-9] matches any character not 0-9. |
| | Match previous or next character/group | (Mon|Tues)day matches “Monday” or “Tuesday” |
{ } | Matches a specified number of occurrences of the previous | [0-9]{3} matches “315” but not “31”
[0-9]{2,4} matches “12”, “123”, and “1234” [0-9]{2,} matches “1234567…” |
^ | Beginning of a string. Or within a character range [] negation | ^http matches strings that begin with http, such as a url.
[^0-9] matches any character not 0-9. |
$ | End of a string | ing$ matches “exciting” but not “ingenious” |
Expression Syntax | Folder Path Examples | Use Details |
.* | //Production/ExternalFeed/.* | Sync everything under a folder including subfolders |
\s | //Bids/Submission\sRequests/.* | Any folders with a space (i.e. /Submission Requests) must be replaced with the \s character |
[^/]*\.ext | //CustomerFeed/Reports/[^/]*\.csv | Sync everything under a folder with a specific file type, including subfolders |
.*\.ext | //Engineering/.*\.csv, //Blueprints/.*\.dwg | Sync specific file type in folder, excluding subfolders |
.*\.ext$ | //folder/subfolder/.*\.csv$ | Add $ at end to ensure that the .ext is the very end of the path |
function main(syncContext) { if (syncContext.syncTargetInfo.path != null && syncContext.syncTargetInfo.path.indexOf(“/Folder/Path”) != -1) syncContext.syncTargetInfo.path = syncContext.syncTargetInfo.path.replace(“/Folder/Path/”,”/”); } |
Please replace the /Folder/Path in the script with the path indicated in your sync rule to remove the replicated folders. | This will prevent the folder path from the Hosted~FTP~ side being replicated on the receiving side and will place the file directly in the target folder without creating the additional folders
|