We help IT Professionals succeed at work.
Get Started

Renaming a txt file with Julian Date

1,114 Views
Last Modified: 2012-09-04
I have a txt file that is constantly being produced via an "export to txt" command using sqlcmd from the command prompt. This txt file is generated everyday based on a SQL script to retrieve records from our Microsoft SQL Server 2008 database. We need to upload each txt file to an FTP site with a specific naming convention. I want to know how to change the name of the txt file to THAT specific naming convention automatically via one method everyday.

The convention is as follows:

CCCCC{2012}{Julian Date}01

where the CCCCC represents a static value (which is my company's name)

the 2012 is the current year...which also could be static ... until the year changes of course

the Julian date (three digit number)

and the 01 is also a static constant

Example:

APPLE+2012+JULIANDATE+01. The + just means its all concatenated together.

The txt file is exported with some arbitrary value lets say : 123456.txt  but we want itt ---> APPLE201236501.txt. for example.

If our batch is running on a job everyday to produce this txt file... how could we set up another automation to rename it once it's created to that naming convention?
Comment
Watch Question
Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE