I work in media production at a university, we work on Mac systems, but our servers are windows based. Illegal characters & long file names are causing us problems when transferring our production files to the server.
To prevent file transfers failing & being sent to a holding pen in our DAM system i'm looking to create a simple Automator App that can be used by the production team to do the following;
- Accept source folder as input for the app.
- Scan contents & replace the following characters
()\/[]"*?<>|+with an underscore. - Scan contents & for file names longer than 100 characters
- Log / report on the affected files for our producers to amend.
Within Automator I have had success with replacing the illegal characters using a find & replace rule for each, but I'm not sure of the apple script that would be required to check the file name lengths & reporting all changes.
I'll be eternally grateful if anyone would be able to suggest a route forwards!
Obviously, I have no clue what you might be passing along, nor how you might be replacing the text in filenames, nor exactly what you would like to report, as you don't really provide any of those details. However, here is a straightforward way to test for filenames longer than a given length within automator.
To provide the initial file list to test, I begin with three actions:
This will pass along a list of alias file objects to the fourth 'run applescript' action, as
input.This should be run when a folder is selected in the Finder.
Essentially, what this does is take the input (i.e. list of file aliases) and create corresponding lists of filenames and filename lengths. The script then loops through the list of lengths looking for items > 100 and and returns a list of matching filenames. If instead, you
set end of longList…to items fromfListthen it will return a list of file aliases.If this isn't what you're looking for, please advise. The above works under Sierra.