Rename bulk files based on data within a CSV RRS feed

  • Question

  • Hello

    I need your help with regards to bulk renaming files using data within a CSV. I currently have over a thousands documents on my PC that contain a number only as the filename. For example, C:\Documents\Folder1\568793.docx.

    I also have a CSV which not only contains the number the document was assigned but also a more meaningful description. For example, Cell A1 '568793-JoeBloggsCV.docx'. There's a reason to why the export only took the number but that's a different story.

    So now I have all of these documents on my PC with a filename containing just numbers, though finding the document that I want is going to prove difficult.

    Question: How can I perform a bulk rename on every physical file using the data from the CSV. For example, if document filename contains 568793, then rename to 568793-JoeBloggsCV.docx.

    Every document will have it's own number so there will not be any conflicts. However it is just a case of getting the filename renamed to the same description in the CSV.

    Are you able to help? VBS would be ideal unless there is a better way of carrying out the above.

    Hope this makes sense.

    Thanks in advance.

    Thursday, January 31, 2013 10:27 AM


  • Look at the learning link at the top of this page. There are many examples of how to do things like renaming files and reading CSV files.

    This forum is here to help people who need to write scripts for administrative purposes and not to write custom code on demand.  You are free to try your hand at writing a script.  If you have never written a script then I recommend learning PowerShell as it will be more useful going forwards.

    Start here: http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    Here is an example of using a csv file:

    $csvdata=Import-Csv file.csv
    $csvfile | 
               rename $_.FIlename $_.description + $_.filename

    Of course that will not work because what you have posted does not contain enough information to correctly determine how to do what you are thinking.  We cannot see what you are seeing.

    Study the material and think about how to do what you are trying to accomplish.  Write it down in simple English in a step-by-step fashion.  In no time you will be writing your script.


    Thursday, January 31, 2013 11:04 AM