- Oct
- 364
- 17
I have a set of files with names in the format SmithAdj20180506.txt and SmithRcpt20180506.txt
I'm trying to add an underscore after Smith. (I'm also hyphenating the dates and adding an underscore before the date, but I have code to handle that.)
I tried RENAME Smith*.txt Smith_*.txt but that results in Smith_dj20180506.txt
I can't just use RENAME Smith???? {etc.} because the filenames aren't all the same length.
It seems I should be able to replace part of a filename with something that's not the same length, basically a REPLACE option that renames the file.
I do know how to pull the files with @findfirst[] and @findnext[], create a string with the new name, and rename the file to the new string, which is what I'm doing with the date portion, but it seems there should be an easier way for simpler things like "replace Smith with Smith_".
I'm trying to add an underscore after Smith. (I'm also hyphenating the dates and adding an underscore before the date, but I have code to handle that.)
I tried RENAME Smith*.txt Smith_*.txt but that results in Smith_dj20180506.txt
I can't just use RENAME Smith???? {etc.} because the filenames aren't all the same length.
It seems I should be able to replace part of a filename with something that's not the same length, basically a REPLACE option that renames the file.
I do know how to pull the files with @findfirst[] and @findnext[], create a string with the new name, and rename the file to the new string, which is what I'm doing with the date portion, but it seems there should be an easier way for simpler things like "replace Smith with Smith_".