XinYoung Posted January 26, 2018 Posted January 26, 2018 (edited) Hello again, I'm trying to use the FileMove function to rename a bunch of text files. Some of the files have "_1" at the end of their name, for example, "File123_1.txt". I want to remove the "_1" so it would become "File123.txt". What I currently have... FileMove($sSource & "\*_1.txt", $sDestination & "\*.txt") But since I'm using a wildcard, it doesn't appear to be working. I think it's just replacing .txt with .txt. Am I going about this the wrong way? How can I use wildcards and still accomplish this? Any help is greatly appreciated ^__^ Edited January 26, 2018 by XinYoung
xcaliber13 Posted January 26, 2018 Posted January 26, 2018 (edited) This should do what you are looking to do Local $sData $FileList = _FileListToArray("C:\Temp", "*"&"_1"&".txt", $FLTA_FILES) For $i = 0 To UBound($FileList) -1 $sData = StringReplace($FileList[$i], "_1", "") FileMove("C:\Temp\"&$FileList[$i], "C:\Temp\Temp\"&$sData) Next Edited January 26, 2018 by xcaliber13
mikell Posted January 26, 2018 Posted January 26, 2018 ...but be sure that both files "File123.txt" and "File123_1.txt" don't exist in the same folder
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