Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
FileSelectFolder, rawPath
if rawPath =
{
MsgBox, No folder selected.
Exit
}
rawPath := RegExReplace(rawPath, "\\$")
Loop, Files, %rawPath%\*.*
{
rawName = %A_LoopFileName%
rawExt = %A_LoopFileExt%
StringReplace, newName, rawName, _, %A_SPACE%, All
oldFilePath := rawPath . "\" . A_LoopFileName . "." . rawExt
newFilePath := rawPath . "\" . newName . "." . rawExt
FileMove, %oldFilePath%, %newFilePath%, 0
}
I've ran the script with While true before the loop to test, and the strings get replaced and stored correctly, so I'm assuming FileMove fails for some reason...