Need to rename files associated to sql records

Posted on 2011-10-03
Last Modified: 2012-05-12
We have a vended app that we are moving away from.  The system stores links to videos.  The vendor changed the file names to guids so they don't make sense if you look at them through windows explorer.  I found the translation table in the database.  Here is an example:

MediaElementID                        displayName
abcd123456789xxx                 vs TeamA

Any thoughts on how I can rename the files using this table?  Long shot but was curious if anyone had any thoughts.
Question by:martyuni
    LVL 7

    Accepted Solution

    use a select statement to create command lines, that you can copy and paste into a command window or script.

    select 'ren "' + MediaElementID + '" "' +DisplayName + '"' from table


    Author Comment

    Will give that a try, thanks tlovie

    Author Comment

    I get the following error:

    Msg 402, Level 16, State 1, Line 1
    The data types varchar and uniqueidentifier are incompatible in the add operator.

    Author Comment

    I figured it out, had to convert he guid to varchar.  Thanks for the help

    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.

    INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 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

    17 Experts available now in Live!

    Get 1:1 Help Now