cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fowmy
Regular Visitor

Rename Mp3 Files in a Folder using the Title in the metadata properties

Hay Folks!,
I am new to Flows 🙂
I am trying to build a flow in Power Automate Desktop to rename a bunch of Mp3 files based on the Title property in the corresponding detail section of each file. Hope the following screenshot explains it all.
Thanks

Fowmy_0-1650898879761.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
JamesP_MSFT
Microsoft
Microsoft

@Fowmy if the answer solved your issue, please mark the thread as resolved.
Thank you.

View solution in original post

3 REPLIES 3
VJR
Super User
Super User

If I have a folder with file names and their titles in the below format (as an example)

 

VJR_1-1650946158009.png

 

 

They get renamed to Title after running the Flow

 

VJR_3-1650946606313.png

 

 

 

This is a vbscript approach. You can use anything else like Powershell etc.

The script used is:

 

    Dim oAppShell, oFolder, output
    
    Set objFso = CreateObject("Scripting.FileSystemObject")
    Set oAppShell = CreateObject("Shell.Application")
    
    varFolderPath = "%FolderPath%"
    Set oFolder = oAppShell.Namespace(varFolderPath)
    
    
    For Each oItem In oFolder.Items
        'Check here if title is empty
      
      'If a file with already same name exists while moving then it will throw error. Please handle accordingly
        objFso.MoveFile oItem.Path, varFolderPath & oFolder.GetDetailsOf(oItem, 21) & ".mp3" '21 is to get the Title
    Next
      
      

 

Copy paste the below code in a blank flow editor and check the outputs.

Please refer the green comments inside the vbscript.

 

SET FolderPath TO $'''C:\\Test\\'''
Scripting.RunVBScript VBScriptCode: $'''    Dim oAppShell, oFolder, output
    
    Set objFso = CreateObject(\"Scripting.FileSystemObject\")
    Set oAppShell = CreateObject(\"Shell.Application\")
    
    varFolderPath = \"%FolderPath%\"
    Set oFolder = oAppShell.Namespace(varFolderPath)
    
    
    For Each oItem In oFolder.Items
        \'Check here if title is empty
      
      \'If a file with already same name exists while moving then it will throw error. Please handle accordingly
        objFso.MoveFile oItem.Path, varFolderPath & oFolder.GetDetailsOf(oItem, 21) & \".mp3\" \'21 is to get the Title
    Next
      
      ''' ScriptOutput=> VBScriptOutput ScriptError=> ScriptError
Display.ShowMessageDialog.ShowMessage Message: $'''DONE''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed

# [ControlRepository][PowerAutomateDesktop]

{
  "ControlRepositorySymbols": [],
  "ImageRepositorySymbol": {
    "Name": "imgrepo",
    "ImportMetadata": {},
    "Repository": "{\r\n  \"Folders\": [],\r\n  \"Images\": [],\r\n  \"Version\": 1\r\n}"
  }
}

 

 

 

JamesP_MSFT
Microsoft
Microsoft

@Fowmy if the answer solved your issue, please mark the thread as resolved.
Thank you.

Fowmy
Regular Visitor

Thanks for the support @VJR 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Top Kudoed Authors
Users online (5,464)