AHK batch rename files script Topic is solved
AHK batch rename files script
Hello, thank you for taking the time to read my post.
I have a large list of .mp3 files, each one named differently. However, there is one character that shows up in every file.
What I would like to do is rename the file as to where any text before said character is removed, and the rest is kept as is.
Example:
Before: Artist - Title.mp3
After: Title.mp3
Would this be possible with AutoHotKey? If so, how would I go about achieving it?
Please note that I am not too experienced with AHK, and also slightly dumb.
I have a large list of .mp3 files, each one named differently. However, there is one character that shows up in every file.
What I would like to do is rename the file as to where any text before said character is removed, and the rest is kept as is.
Example:
Before: Artist - Title.mp3
After: Title.mp3
Would this be possible with AutoHotKey? If so, how would I go about achieving it?
Please note that I am not too experienced with AHK, and also slightly dumb.
Re: AHK batch rename files script
Yes, this is straightforward using RegExReplace or InStr with SubStr.
It seems you’d want to also remove the space after that character as well. Trim can help with that if it doesn’t always have a following space (although the RegExReplace method can handle it directly).
It seems you’d want to also remove the space after that character as well. Trim can help with that if it doesn’t always have a following space (although the RegExReplace method can handle it directly).
Re: AHK batch rename files script
You would also use Loop, Files and FileMove.
Re: AHK batch rename files script
just use Bulk Rename Utility instead
Re: AHK batch rename files script Topic is solved
Code: Select all
dir = %A_ScriptDir%\t
Loop, Files, %dir%\*.mp3
FileMove, %A_LoopFilePath%, % dir "\" Trim(SubStr(A_LoopFileName, Instr(A_LoopFileName, "-") + 1))
MsgBox, 64, Done, Done!
Re: AHK batch rename files script
Thank you for your reply!mikeyww wrote: ↑03 Dec 2022, 11:15Code: Select all
dir = %A_ScriptDir%\t Loop, Files, %dir%\*.mp3 FileMove, %A_LoopFilePath%, % dir "\" Trim(SubStr(A_LoopFileName, Instr(A_LoopFileName, "-") + 1)) MsgBox, 64, Done, Done!
This worked perfectly, although I had to remove the \t on the first line to get it to work, unsure why that is. Either way, your help is greatly appreciated!
Re: AHK batch rename files script
Thank you for your reply!boiler wrote: ↑03 Dec 2022, 11:03Yes, this is straightforward using RegExReplace or InStr with SubStr.
It seems you’d want to also remove the space after that character as well. Trim can help with that if it doesn’t always have a following space (although the RegExReplace method can handle it directly).
I have read through the wiki pages and I understand how I could've done this now. Your response was very useful, thank you!
Re: AHK batch rename files script
You can use any directory of your choice! (Yeah, I just did what boiler said!)