Hi Experts,
Recently I had some query related to renaming files on the following link -
where
@eetuRobo helped me quite promptly and must say efficiently believing he understood how novice I'm at Power Automate.
Right now, I'm using those suggestions in 3 flows. 2 are running fine. But in the 3rd flow, I need to work with multiple files simultaneously.
But when it comes to moving the renamed files (R041), it moves only 1 file and generates no error. while I want to move every file to a different location depending upon the part a filename contains.
Tried multiple ways to get things done. But at most it moves only 1 file.
Please help
Thanks in advance
The code (flow) is as below -
Display.SelectFileDialog.SelectFiles Title: $'''Choose Files''' InitialDirectory: $'''C:\\Users\\Sanja\\Downloads''' FileFilter: $'''%''%''' IsTopMost: True CheckIfFileExists: False SelectedFiles=> SelectedFiles ButtonPressed=> OpenFiles
IF OpenFiles = $'''Open''' THEN
SET aSpace TO $'''%' '%'''
File.RenameFiles.RenameReplaceText Files: SelectedFiles TextToReplace: $'''_''' ReplaceWith: $'''%' '%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R001
SET oNames TO R001
LOOP FOREACH CurrentItem IN oNames
Text.ChangeCase Text: CurrentItem.NameWithoutExtension NewCase: Text.CaseOption.TitleCase Result=> nName
File.RenameFiles.Rename Files: CurrentItem.FullName NewName: nName KeepExtension: True IfFileExists: File.IfExists.DoNothing RenamedFiles=> R002
File.RenameFiles.RenameReplaceText Files: R002 TextToReplace: $'''Sanjay Gulati Musafir''' ReplaceWith: $'''SGM''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R003
File.RenameFiles.RenameRemoveText Files: R003 TextToRemove: $'''Statement ''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R004
File.RenameFiles.RenameRemoveText Files: R004 TextToRemove: $'''Mth''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R005
File.RenameFiles.RenameReplaceText Files: R005 TextToReplace: $'''Yrh''' ReplaceWith: $''' Yrh''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R006
File.RenameFiles.RenameReplaceText Files: R006 TextToReplace: 78406212019 ReplaceWith: $'''78406212019%aSpace%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R007
File.RenameFiles.RenameReplaceText Files: R007 TextToReplace: 78406212053 ReplaceWith: $'''78406212053%aSpace%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R008
File.RenameFiles.RenameReplaceText Files: R008 TextToReplace: 74008716118 ReplaceWith: $'''74008716118%aSpace%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R009
File.RenameFiles.RenameRemoveText Files: R009 TextToRemove: $'''Whatsapp Image ''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R010
File.RenameFiles.RenameRemoveText Files: R010 TextToRemove: $'''Whatsapp Video ''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R011
File.RenameFiles.RenameRemoveText Files: R011 TextToRemove: $'''New Doc ''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R012
File.RenameFiles.RenameRemoveText Files: R012 TextToRemove: $'''Screenshot ''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R013
File.RenameFiles.RenameRemoveText Files: R013 TextToRemove: $'''Img_''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R014
File.RenameFiles.RenameRemoveText Files: R014 TextToRemove: $'''Vid_''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R015
File.RenameFiles.RenameRemoveText Files: R015 TextToRemove: $'''-''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R016
File.RenameFiles.RenameReplaceText Files: R016 TextToReplace: $''' At ''' ReplaceWith: $'''%' '%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R017
File.RenameFiles.RenameReplaceText Files: R017 TextToReplace: $'''_''' ReplaceWith: $'''%' '%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R018
File.RenameFiles.RenameRemoveText Files: R018 TextToRemove: $''' Retail Platinum Norm''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R019
File.RenameFiles.RenameRemoveText Files: R019 TextToRemove: $''' Retail Platinum N''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R020
File.RenameFiles.RenameRemoveText Files: R020 TextToRemove: $''' Retail Hpcl Norm''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R021
File.RenameFiles.RenameRemoveText Files: R021 TextToRemove: $''' Retail Amazon Norm''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R022
File.RenameFiles.RenameReplaceText Files: R022 TextToReplace: $'''%' '%''' ReplaceWith: $'''%' '%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R023
File.RenameFiles.RenameReplaceText Files: R023 TextToReplace: $'''%' '%''' ReplaceWith: $'''%' '%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> R024
File.RenameFiles.RenameReplaceText Files: R024 TextToReplace: $'''Sgm''' ReplaceWith: $'''SGM''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R025
File.RenameFiles.RenameReplaceText Files: R025 TextToReplace: $'''Sh''' ReplaceWith: $'''SH''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R026
File.RenameFiles.RenameReplaceText Files: R026 TextToReplace: $'''SHail''' ReplaceWith: $'''Shail''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R027
File.RenameFiles.RenameReplaceText Files: R027 TextToReplace: $'''Spr''' ReplaceWith: $'''SPR''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R028
File.RenameFiles.RenameReplaceText Files: R028 TextToReplace: $'''SPRiha''' ReplaceWith: $'''Spriha''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R029
File.RenameFiles.RenameReplaceText Files: R029 TextToReplace: $'''Pdf''' ReplaceWith: $'''PDF''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R030
File.RenameFiles.RenameReplaceText Files: R030 TextToReplace: $'''Emi''' ReplaceWith: $'''EMI''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R031
File.RenameFiles.RenameReplaceText Files: R031 TextToReplace: $'''Neft''' ReplaceWith: $'''NEFT''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R032
File.RenameFiles.RenameReplaceText Files: R032 TextToReplace: $'''Upi''' ReplaceWith: $'''UPI''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R033
File.RenameFiles.RenameReplaceText Files: R033 TextToReplace: $'''Rtgs''' ReplaceWith: $'''RTGS''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R034
File.RenameFiles.RenameReplaceText Files: R034 TextToReplace: $'''Icici''' ReplaceWith: $'''ICICI''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R035
File.RenameFiles.RenameReplaceText Files: R035 TextToReplace: $'''Sbi''' ReplaceWith: $'''SBI''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R036
File.RenameFiles.RenameReplaceText Files: R036 TextToReplace: $'''Hdfc''' ReplaceWith: $'''HDFC''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R037
File.RenameFiles.RenameReplaceText Files: R037 TextToReplace: $'''Iwish''' ReplaceWith: $'''iWish''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R038
File.RenameFiles.RenameReplaceText Files: R038 TextToReplace: $'''Ccard''' ReplaceWith: $'''CCard''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R039
File.RenameFiles.RenameReplaceText Files: R039 TextToReplace: $'''Itr''' ReplaceWith: $'''ITR''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R040
File.RenameFiles.RenameReplaceText Files: R040 TextToReplace: $'''Ppf''' ReplaceWith: $'''PPF''' IfFileExists: File.IfExists.Overwrite RenamedFiles=> R041
END
SET fName TO R041
LOOP FOREACH Current2 IN fName
IF Contains(Current2, $'''068529266''', False) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\ICICI SGM 082601502857 529266068''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, 159529631, True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\ICICI SH 082601001624 529631159''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, 773531541, True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\ICICI SPR 082601503182 531541773''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, 74008716118, True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\SBI SGM 64020211900''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, 78406212019, True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\SBI SH 39699720821''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, 78406212053, True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\SBI SPR 39704918751''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, $'''SGM PPF''', True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\SBI SGM 54006821736 PPF''' IfFileExists: File.IfExists.Overwrite
ELSE IF Contains(Current2, 54006821736, True) THEN
File.Move Files: Current2 Destination: $'''C:\\Users\\Sanja\\Dropbox\\eBills\\Bank Statements\\SBI SGM 54006821736 PPF''' IfFileExists: File.IfExists.Overwrite
END
END
END