sbrady Posted October 31, 2012 Share Posted October 31, 2012 1. I have selected 3 files that I need to rename. 2. I found a script that displays an array window with all selected files.AND 2 OTHER FILES, all 5 files show up in the code below in the variable $File_Name. 3. I need to cycle through the selected items and rename them. 4. I will need to check the variable to see if the file name contains certain words, do I use Strginstg 5. what loop do I use, For.....next thanks for any help ; START SHAWN's CODE ; repeat with the selected items For $File_Name = 1 To $aSelection ; check if file name contains "Full MIX" or "SOT MIX" or "M&E MIX" ; rename the variable $File_Name MsgBox(0, "File Name", $File_Name) Next ; END SHAWN's CODE Link to comment Share on other sites More sharing options...
water Posted October 31, 2012 Share Posted October 31, 2012 And the question is? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sbrady Posted October 31, 2012 Author Share Posted October 31, 2012 And the question is?#3 how do I loop through the variable $File_name and search the name of the file for a certain word Link to comment Share on other sites More sharing options...
Mechaflash Posted October 31, 2012 Share Posted October 31, 2012 You are trying to rename all files that are named "Full MIX", "SOT MIX" and "M&E MIX" to what? Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
sbrady Posted October 31, 2012 Author Share Posted October 31, 2012 I can do the rename, I just need to get the file name in a loop the original name will be something like "RR123 Smith, Bob v1 - FULL MIX.wav" rename will be "RR123 Smith Bob FULL MIX v1.wav" thanks for all the help Link to comment Share on other sites More sharing options...
Mechaflash Posted October 31, 2012 Share Posted October 31, 2012 And you're stating that $aSelection contains the list of files you want to search through? Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
sbrady Posted October 31, 2012 Author Share Posted October 31, 2012 yes, correct Link to comment Share on other sites More sharing options...
Mechaflash Posted October 31, 2012 Share Posted October 31, 2012 (edited) Given that $aSelection[0] is a file name (not either a file count nor the Full Path to the file) Local $sBaseDir = "C:PathToFile", $sOutDir = "C:PathToOutputDirectory", $sRename = "rename.wav" Local $aSearch[3] = ["Full MIX","SOT MIX","M&E MIX"] Local $i For $file in $aSelection $i = 0 For $term in $aSearch $i+=1 If StringInStr($file, $term) Then If Not FileMove($sBaseDir & $file, $sOutDir & $sRename, 8) Then _ ConsoleWrite("Failed to move file: " & $file & @CRLF) ExitLoop Else If $i = 3 Then ConsoleWrite("No match in file: " & $file & @CRLF) EndIf Next Next Edited October 31, 2012 by Mechaflash Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Mechaflash Posted October 31, 2012 Share Posted October 31, 2012 not tested... let me know if it spits out any errors. Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now