Question: replace illegal characters in a file name

Discussion, questions and support.
Post Reply
gbotes
Posts: 18
Joined: Jul 13th, ’18, 13:45

Post by gbotes » Jul 16th, ’19, 13:14

I use Text Expander and Input Selection features to complete a little form that prompts me for information used to build a file name so that I can save documents and forms using a schema. The input selection form opens up when I type a phrase in a software application's "Save As" dialog, and then sens the input gathered from the form to the "Save As" dialog. I then click the "Save" button and the software application saves my file (e.g. it could be an MS Word file or a PDF form, etc.)

Is there a way to replace illegal filename characters that might creep in to the input fields (common culprits are "/" and ":") when FastKeys sends the input gathered to the software application's "Save As" dialog?

In the FastKeys settings, the Text Expander string I use is "!f" and the content of the Substitute field is "%A_YYYY%%A_MM%%A_DD%%A_Hour%%A_Min%%A_Sec%_%SELECT_RefNo%_%SELECT_DescR%_%SELECT_Dir%_%SELECT_OrgUnitNo%_%SELECT_Desc%"
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Jul 17th, ’19, 22:07

Why can't you define the selections to not contain illegal characters?
gbotes
Posts: 18
Joined: Jul 13th, ’18, 13:45

Post by gbotes » Jul 18th, ’19, 07:05

Tom wrote: Jul 17th, ’19, 22:07 Why can't you define the selections to not contain illegal characters?
If you mean by building validation into the input fields, how does one do that? I can't recall seeing it in the help doc but maybe I missed it? I find when doing copy and paste from the descriptions or job titles or file references there are often invalid characters that appear.
gbotes
Posts: 18
Joined: Jul 13th, ’18, 13:45

Post by gbotes » Jul 18th, ’19, 08:04

Just a quick update on this question: I had an idea and created an AHK script to handle the character replacement from a shortcut key combination. While it's not as good as "on-the-fly" or in process handling, but it is quicker and saves me manually fixing the filenames. I'm happy with this approach unless someone has a better idea. When I've tested it more extensively, I'll share the script in the appropriate forum.
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jul 18th, ’19, 12:01

Since you only use SELECT macros (and not INPUT), all the selection texts are pre-defined so there is no need for additional validation.

What you need could easily be done with a simple script - please post the requirements and I will try to help.
gbotes
Posts: 18
Joined: Jul 13th, ’18, 13:45

Post by gbotes » Jul 18th, ’19, 12:35

Actually I use the TEXT box which is one of the SELECT macros. This is is where I type in or paste text to form part of the filename(s), so that is not standardised. Your question prompted me to look at INPUT macros in the help doc but there isn't enough info (e.g. some examples) for me there to enable me to make sense of it well enough to use it.

I tried to post a screenshot of the script dialog that from when I run my script, but it looks as if the forum doesn't allow me to upload images, only to insert links to them, so I couldn't do that.

Fastkeys hangs and then crashes if I try to insert a command code into the TextExpander, so that was another option I considered but couldn't get it to work. But calling an AHK script in from a shortcut key is working. it just means I need two steps instead of one.

Is there a resource with examples of the various features and tools in FastKeys? It seems very powerful, but maybe I'm just old or something - I seem to struggle to grasp the help document explanations.

Thank you for all the responses so far. It's all been helpful, even if only to give me some hint as to something else to try. I am finding FastKeys very useful, and am trying to get my employer to consider getting licences for all the employees in my team.
gbotes
Posts: 18
Joined: Jul 13th, ’18, 13:45

Post by gbotes » Jul 18th, ’19, 12:49

OK, another update on my last post:

I rolled back to FastKeys 4.18 and using INSERT COMMAND CODE worked fine. So now, FastKeys does exactly what I needed all in one go. :D

Update: The problem with INSERT COMMAND CODE hanging on my laptop must have been some other kind of software glitch. I thought rolling back to 4.18 resolved it but when I subsequently tested using 4.19 and 4.20 everything worked correctly, so it could not have been due to FastKeys. Maybe it was even something I was doing wrong that I suddenly started doing right.

So my question is answered. Thanks for all responses.
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jul 18th, ’19, 19:44

gbotes wrote: Jul 18th, ’19, 12:35Fastkeys hangs and then crashes if I try to insert a command code into the TextExpander, so that was another option I considered but couldn't get it to work. But calling an AHK script in from a shortcut key is working. it just means I need two steps instead of one.

Is there a resource with examples of the various features and tools in FastKeys? It seems very powerful, but maybe I'm just old or something - I seem to struggle to grasp the help document explanations.
Thanks for the update. Let us know if you will experience the issue again - you can copy and paste your command here instead of posting screenshots.

Just an idea: your activity could be automated even further - selecting a Save As menu, entering the strings, pressing Ok button, could all be done with one shortcut...

Also, please let us know which part of the documentation is not clear - happy to hear your suggestions and improve it. ;)
Post Reply