Hi all,
I created 2 lists. List a - Subfolders, b - files in format .txt
I want to compare the names of subfolders and names of files and is they are the same, do some actions.
To get a list "a" I running "Get Subfolders if folder" and the output is "c:/user/etc/etc/etc/etc/folder name"
e.g. C:/User/folder 1/folder 2/folder 3/testfolder
To get a list "b" I running "Get files in folder" and the output is "c:/user/etc2/etc2/etc2/etc2/file name.txt
e.g. C:/User/folder 1/folder 4/folder 5/folder 6/testfolder.txt
Then I will compare them via 2 "for each".
How I can get the exact folder name and file name without a path? (in this example name will be a "testfolder")
Because now it's comparing the whole path, where I need only names.
Solved! Go to Solution.
The text representation of a folder variable is its full name, but you can access the short name by adding .Name in the variable call.
Try pasting the following into your flow and run it, and see if it explains:
Folder.GetSpecialFolder SpecialFolder: Folder.SpecialFolder.DesktopDirectory SpecialFolderPath=> SpecialFolderPath
Folder.GetSubfolders Folder: SpecialFolderPath FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
Variables.CreateNewList List=> List_Folders_NameOnly
LOOP FOREACH CurrentItem IN Folders
Variables.AddItemToList Item: CurrentItem.Name List: List_Folders_NameOnly NewList=> List_Folders_NameOnly
END
You can also use %CurrentItem.Name% in your comparison step, instead of making a dedicated list of the folder names.
The text representation of a folder variable is its full name, but you can access the short name by adding .Name in the variable call.
Try pasting the following into your flow and run it, and see if it explains:
Folder.GetSpecialFolder SpecialFolder: Folder.SpecialFolder.DesktopDirectory SpecialFolderPath=> SpecialFolderPath
Folder.GetSubfolders Folder: SpecialFolderPath FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
Variables.CreateNewList List=> List_Folders_NameOnly
LOOP FOREACH CurrentItem IN Folders
Variables.AddItemToList Item: CurrentItem.Name List: List_Folders_NameOnly NewList=> List_Folders_NameOnly
END
You can also use %CurrentItem.Name% in your comparison step, instead of making a dedicated list of the folder names.
Thanks for a quick response, but am new to PAD, so struggle to understand, where should I use this code?
e.g. what I have.
the output:
Where I need output:
You just CTRL+C copy the code text and CTRL+V paste it where you normally put your actions.
I don't understand your intention well enough to give you better advice 😱
Compare folder name with a file name.
Actually that's working with subfolders names and file name.
By any chance do you know how to get a filename without an extension? right now I getting filename.gvf
Of course, I can split and then remove an index 1. But maybe there is a simpler way.
Before your help, I got it working with this Frankenstein, but now I can make it clean and simple. Thank you!
Just like you are able to use .Name with Folder variables, File variables have some useful properties. You can find an overview here: Datatype properties - Power Automate | Microsoft Docs