I need to make a macro to rename a file using only a section of the name.
The problem is that the first part of the name change any day and I need to ignore this part and rename the file
I need to do:
RENAME *.0651.TXT , AUDIT.0651.TXT
How can I make this macro?
Thank's for support.
Regards
Giovanni Roi
Rename File with partial name
Moderators: JRL, Dorian (MJT support)
-
- Junior Coder
- Posts: 21
- Joined: Fri Jul 03, 2009 4:36 pm
- Location: Milan,Italy
Try this:
Code: Select all
GetFileList>c:\temp\*.txt,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>k=k+1
Let>myfile=file_names_%k%
ExtractFilePath>myfile,path_only
Length>myfile,myLen
Position>.,myfile,1,nPos,TRUE
Add>nPos,1
MidStr>myfile,nPos,myLen,strSub
RenameFile>myfile,%path_only%\audit.%strSub%
Until>k,file_names_count
-
- Junior Coder
- Posts: 21
- Joined: Fri Jul 03, 2009 4:36 pm
- Location: Milan,Italy
Thank's for the solution
Thank's for the solution. I modify only the last line of code in:
"RenameFile>myfile, c:\temp\audit.txt,files"
in this case the code work well.
Thank's
Regards
Giovanni Roi
"RenameFile>myfile, c:\temp\audit.txt,files"
in this case the code work well.
Thank's
Regards
Giovanni Roi
adroege wrote:Try this:
Code: Select all
GetFileList>c:\temp\*.txt,files Separate>files,;,file_names Let>k=0 Repeat>k Let>k=k+1 Let>myfile=file_names_%k% ExtractFilePath>myfile,path_only Length>myfile,myLen Position>.,myfile,1,nPos,TRUE Add>nPos,1 MidStr>myfile,nPos,myLen,strSub RenameFile>myfile,%path_only%\audit.%strSub% Until>k,file_names_count