Tech Off Thread

11 posts

How To Rename Multiple Files

Back to Forum: Tech Off
  • User profile image
    akopacsi

    I have a bunch of files in a folder and I would like to add a prefix to their names. E.g. there are image files named like dsc0001.jpg dsc0002.jpg etc., and I want to rename them like 20081215dsc0001.jpg 20081215dsc0002.jpg
    I know an easy way to do this in mc under Linux, but I would like to learn it in Windows, too. Can you help me?

  • User profile image
    AndyC

    ren * 20081215*

  • User profile image
    PeterF

    Use Total Commander.
    Inside Total Commander select the files you want to rename (using right mouse or invert selection)
    Then:
    File->Multi-Rename Tool

    In the Rename mask: file name textbox enter:
    [YMD]-[hms]-[N]-yourname

    This way you can combine photos of multiple users.
    Good luck,
    Peter

  • User profile image
    Lloyd_Humph

    Windows has built in functionality for stuff like this.

    Select all the files, rename one to 2005-11-09DSC then windows will rename them all ..DSC(0001) ..DSC(0002) etc.

    I think thats what you're looking for.. if not then sorry Smiley

    If Blackberrys are addictive cellphones, Channel9 is the ultimate addictive website.
    Last modified
  • User profile image
    GravityGuy

    If you want to use todays date, try making a batch file like this:

    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=

    It will used today's date to construct a string like 20071216 and prepend it to the file name.

  • User profile image
    Matthew van Eerde

    C:\Users\mateer\Desktop\custom-path>type prepend.bat
    @echo off
    for /f "usebackq delims=" %%i in (`dir /b`) do @move "%%i" "%* %%i"

  • User profile image
    Bas

    From the replies above, I'd hazard a guess and suggest that a new version of explorer wouldn't do half-bad if it implemented a nice multiple-file-renaming GUI.

  • User profile image
    odujosh

    System.IO and maybe regulaur expressions. Although I could see how this isnt a suggestion for a non dev. I am sure by being on here you can write a simple console project.

  • User profile image
    AndyC

    odujosh wrote:
    System.IO and maybe regulaur expressions. Although I could see how this isnt a suggestion for a non dev. I am sure by being on here you can right a simple console project.


    Um, that's really over-complicating things. Not only is it a single DOS command, but it's pretty much the textbook example for "Why DOS globbing is superior to *nix"

  • 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.

  • User profile image
    kidzi

    The problem with the file system and other ways mentioned, is that pictures have meta data which stores the 'date photo taken' - and it is not always the date modified (if you removed redeye or something beforehand).

    I had to write a tool which loads the date modified so that I can sort the stuff and do a basic filter (text with a # which inserts the numbers for the selection). I've never seen another tool out there which does it, and it's pretty easy to make. I'd suggest going that route if you have a lot of photos and really want the date to be accurate.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.