Rename All files to .txt and keep original filenames

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
probbins
Newbie
Posts: 9
Joined: Wed Jun 01, 2011 9:20 pm

Rename All files to .txt and keep original filenames

Post by probbins » Wed Jun 01, 2011 9:57 pm

Right now I use the code below to rename .dat to .txt files and it works fine as long as I'm running the macro on the same day as I receive the files. What I'm looking for, is a way to rename the files to text and keep the original file name, regardless of what day the macro runs.

These are examples of the files I receive daily:
MonthDayYear and file name
06012011_A_newbiz.dat
06012011_C_newbiz.dat
06012011_D_newbiz.dat


**This is the code that I use currently to rename the files to text and keep the original name**
//Rename from .DAT to .TXT
Year>yyyy
Month>mm
Day>dd
RenameFile>C:\NewBusiness\%mm%%dd%%yyyy%_A_newbiz.dat,C:\NewBusiness\%mm%%dd%%yyyy%_A_newbiz.txt

RenameFile>C:\NewBusiness\%mm%%dd%%yyyy%_C_newbiz.dat,C:\NewBusiness\%mm%%dd%%yyyy%_C_newbiz.txt

RenameFile>C:\NewBusiness\%mm%%dd%%yyyy%_D_newbiz.dat,C:\NewBusiness\%mm%%dd%%yyyy%_D_newbiz.txt



In short, if a file comes over today as 06012011_A_newbiz.dat...
I want to be able to rename that file to 06012011_A_newbiz.txt regardless of what day the macro runs.

I've been stuck on this for awhile now so any help would be MUCH appreciated!

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jun 01, 2011 10:12 pm

If the file names are as simple as your samples you can probably just use the DOS ren command.

Code: Select all

Let>RP_WAIT=1
Run>cmd /c ren C:\NewBusiness\*.dat *.txt

probbins
Newbie
Posts: 9
Joined: Wed Jun 01, 2011 9:20 pm

Post by probbins » Thu Jun 02, 2011 1:58 pm

Thank you so much! Just tested the code out and it works perfectly.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts