Tech Off Post

Single Post Permalink

View Thread: How To Rename Multiple Files
  • User profile image
    odujosh

    Complicated ? less than 5 lines of code. More control. And I didn't have to use/learn/groke yet another syntax. The code is self explanatory.

     

    using System;

    using System.IO;

    namespace FileRenamer

    {

    class Program

    {

    static void Main(string[] args)

    {

    string location = @"C:\Images\";

    string[] images = Directory.GetFiles(location);

    foreach (var image in images)

    {

    FileInfo fi = new FileInfo(image);

    if (!fi.Extension.Equals(".db"))

    {

    fi.MoveTo(

    fi.Directory + @"\" + DateTime.Now.ToShortDateString().Replace("/", "") + fi.Name);

    }

    }

    }

    }

    }

    To me:
    set d=%date%
    set ff=%d:~0,4%%d:~5,2%%d:~8,2%
    for %%i in (dsc*.jpg) do ren %%i %ff%%%i
    set d=
    set ff=

    Is pretty much garbage.