File system task to move and rename the file

Posted on 2011-04-20
Last Modified: 2012-05-11
Hi experts, I need to move a file as well as rename it with a datestamp.
For example the source location is X:\BP.txt
I need to move it to X:\Archive_files\
and rename it to X:\Archive_files\BP_04202011.txt
So do I use two file system tasks, please help me through?
Question by:sqlcurious
    LVL 7

    Accepted Solution

    each step are clearly explain here:

    In the example he had to move many files at once.  He used the Loop for each file in folder, but you don't need this if you only have one file to move.

    LVL 21

    Expert Comment

    by:Alpesh Patel
    Yes you can.

    Expert Comment

    Stored Procedure:

          @TodayDate as varchar(40),
          @cmdstr as varchar(250),
    SET @TodayDate = CONVERT(varchar(10), GETDATE(), 112)
    SET @cmdstr = 'MOVE /Y "X:BP.txt" "X:\Archive_Files\BP_'+@TodayDate+'.ERR"'
    EXEC master..xp_cmdShell @cmdstr ,no_outpu

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    Viewers will learn how the fundamental information of how to create a table.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now