Powerautomate remove word from string - power-automate

Afternoon,
Apologies if this has been answered but i've looked around and couldn't find a answer.
I have a MS form which uploads files but after the file name it adds _anonymous
e.g instead of picture.jpg its picture_anonymous.jpg
I'm looking for a way to remove the "_anonymous" keeping the original filename and extention.
I know it can be done with the expressions but its not something im used to.
Thanks
various expressions but its not my strong suit

You could use a couple of expressions in a Move or Rename file action (assuming that the files from the MS Forms question get stored on the OneDrive).
Below is an example
Make sure you replace my question id by your specific question id
1.Add a Move or Rename file action directly after the Get response details
a.Use the expression below to retrieve the file identifier:
first(json(outputs('Get_response_details')?['body/red0589afa18d4cf9904ce51ad931c81a']))['id']
b.Use the expression below to replace the _anonymous string by nothing, which will remove it
replace(first(json(outputs('Get_response_details')?['body/red0589afa18d4cf9904ce51ad931c81a']))['name'], '_anonymous', '')

Related

Can files be deleted in a folder if they don't contain a specific word using Power Automate?

I currently have a folder which has photos dumped into it, I am looking to delete all files that do not contain a specific word (which is present in all file names in which I want to keep).
I am hoping this can be done with power automate as there is 100's of photos and I want to improve its efficiency.
I look forward to learning from somebody!
Image below, it seems the flow ran successfully.
enter image description here
You could use a Get files (properties only) action and use a filter array afterwards. In the filter array you could check if the Name field does not contain your keyword.
After that you can loop through the results of the filter array and delete the files based on the {Identifier} field.
Below is an example of that approach
Test it properly, because you are deleting files. Otherwise restore from the first or second stage recycle bin ;)

Find Files in Folder - Search Query Includes Parentheses

I have a flow that pulls a list of filenames from an Excel file and then looks for them in a folder. Sometimes the filenames have parentheses in them, which causes issues with the search query and it doesn't even look for the file. I'm not sure how to handle the parentheses, but I don't want to remove the parentheses from the filenames (and ergo the search query). I thought about trimming the parentheses from the search query, but I want to make sure the right file is found. Perhaps I just need a way to escape the parentheses? I'm not sure how to do that though.
Here's a picture of the flow section in question:
I tried to find another post on this but after searching for a while I couldn't find anything, so I'm sorry if this has been answered already!
Any help is appreciated!
Edit: I'm going to try replacing any parentheses found with %28/%29 per Expiscornovus' suggestion.
Can you use a different search mode in the settings of your Find Files in Folder action (OneDriveSearch instead of Pattern)?
Ignore my previous suggested encoding. Inputting the Search query with parentheses should work. Look at the example below.

How can I automatically update all of the filenames for my middlman blog posts after rewriting the titles?

I have a whole load of blog posts in middleman and have just worked on improving the titles, which are written in the frontmatter section at the top of the markdown file. However, the filenames are all still set to the old titles, and retyping them is a pain. Is there a quick way to either regenerate all the filenames from the current title, or get middleman to ignore the filename at build time and create a new filename for the generated HTML based on the current title?
I am not aware of any built-in option that does what you need.
You would have to use your favorite language to build something quick and dirty that does that for you. In pseudocode:
Iterate over all blog files and for each file:
Read the file's contents and extract the new and nice title from the front matter using a regular expression
Rename the file according to your desired naming scheme. You could include the original date (if present), make titles URL friendly etc.
Whether that would be more efficient than manually renaming all files it depends of course on the number of blog posts as well as you programming experience!

PowerBuilder and batch processing

I'm using PowerBuilder 10.5 and as a newbie I'm a bit stuck and since Google isn't giving me a satisfying answer I'm asking some advice from the Stack Overflow group.
I have a Rich Text Edit field in which the user can write something, insert pictures and so forth. Once finished, he goes to the „Search“ command button and clicking it searches for the batch file that will suit his needs (copy that text into an existing word document, create a new word and place the folder on web, and so fort – there are 6 different batches). The code in the clicked event of „Search“ command button is this:
String ls_s
GetFileOpenName('PB_app', ls_s, ls_s, 'BAT', "Win Batch Files (*.BAT),*.BAT", 'C:\Programs\Test')
And here come my problems: I can't connect my app and the selected batch file. I'd like the path of the selected batch file to be visible in the Single Line Edit filed, but I have no idea how to get there, not to mention I'm point blank at how to connect PB app, batch file, how to even say to the batch file – „That text in rich text edit field is the one you have to work with?“…?
So I need some advice, guidance, perhaps some links or names of any literature that would help me understand how it should be done. I've lost two days and got nowhere, and I just need some piece of advice to get me going…
Your problem is that the original programmer used one variable for two return values. If you declare a new string variable and pass it instead of the first ls_s, you'll see this will return you the path. If you run into trouble, PB has a good help file (and the manuals are also online) which covers GetFileOpenName().
Good luck,
Terry

Insert a hyperlink to another file (Word) into Visual Studio code file

I am currently developing some functionality that implements some complex calculations. The calculations themselves are explained and defined in Word documents.
What I would like to do is create a hyperlink in each code file that references the assocciated Word document - just as you can in Word itself. Ideally this link would be placed in or near the XML comments for each class.
The files reside on a network share and there are no permissions to worry about.
So far I have the following but it always comes up with a file not found error.
file:///\\165.195.209.3\engdisk1\My Tool\Calculations\111-07 MyToolCalcOne.docx
I've worked out the problem is due to the spaces in the folder and filenames.
My Tool
111-07 MyToolCalcOne.docx
I tried replacing the spaces with %20, thus:
file:///\\165.195.209.3\engdisk1\My%20Tool\Calculations\111-07%20MyToolCalcOne.docx
but with no success.
So the question is; what can I use in place of the spaces?
Or, is there a better way?
One way that works beautifully is to write your own URL handler. It's absolutely trivial to do, but so very powerful and useful.
A registry key can be set to make the OS execute a program of your choice when the registered URL is launched, with the URL text being passed in as a command-line argument. It just takes a few trivial lines of code to will parse the URL in any way you see fit in order to locate and launch the documentation.
The advantages of this:
You can use a much more compact and readable form, e.g. mydocs://MyToolCalcOne.docx
A simplified format means no trouble trying to encode tricky file paths
Your program can search anywhere you like for the file, making the document storage totally portable and relocatable (e.g. you could move your docs into source control or onto a website and just tweak your URL handler to locate the files)
Your URL is unique, so you can differentiate files, web URLs, and documentation URLs
You can register many URLs, so can use different ones for specs, designs, API documentation, etc.
You have complete control over how the document is presented (does it launch Word, an Internet Explorer, or a custom viewer to display the docs, for example?)
I would advise against using spaces in filenames and URLs - spaces have never worked properly under Windows, and always cause problems (or require ugliness like %20) sooner or later. The easiest and cleanest solution is simply to remove the spaces or replace them with something like underscores, dashes or periods.

Resources