Results 1 to 4 of 4

Thread: Append Date-Time while Renaming files

  1. #1
    Join Date
    Jan 2009
    Posts
    61

    Append Date-Time while Renaming files

    Hi, I want to append date and time to file which I am renaming. How to do it? I have tried following bat file, but not working as I want.
    Code:
    FOR %%V IN (%1) DO FOR /F "tokens=1-5 delims=/: " %%J IN ("%%~tV") 
    DO ECHO Rename "%%V" %%L%%J%%K_%%M%%N%%~xV
    Can you help me to do it?

  2. #2
    Join Date
    Apr 2008
    Posts
    3,270

    Re: Append Date-Time while Renaming files

    Hello, I am using one bat file which first make zip of the file and then rename it in mmddyy format. Just try it.

    Code:
    set mm= %Date:~3,2%
    set dd = %Date:~0,2%
    set yy = %Date:~8,2%
    pkzip -a AL%mm%dd%yy% *.doc
    I think this will solve your problem. Just try this.

  3. #3
    Join Date
    Apr 2008
    Posts
    3,526

    Re: Append Date-Time while Renaming files

    Hello, I have got one bite script which will work for you. Just use it. It will help you in this situation.

    For getting time stamp:
    Code:
    var str timestamp
    set $timestamp=gettime()
    For getting file extension
    Code:
    var str extension
    stex "[^.^l"$ $file >$extn
    Now for adding timestamp to the file name:
    Code:
    set $file = $file + $timestamp
    Again to add extension
    Code:
    set $file = $file + $extension

  4. #4
    Join Date
    Apr 2008
    Posts
    3,297

    Re: Append Date-Time while Renaming files

    Hi, I have got the code which will append date and time while renaming it. Just try to make use of it, if you are getting it. I am not able to know how to use it? But if you got it, then reply me also.

    Code:
    Set date=%date:~10,4%%date:~4,2%%date:~7,2%
    FOR %%V IN (%1) DO Call :DoLoop
    
    :DoLoop
    set OFullFileName=%%V
    Set OFileExt=%FileName:~-4%
    Set OFileName=%OFullFileName:~0,-4%
    Set NFullFileName=%OFileName%%dat%%OFileExt%
    Rename %OFullFileName% %NFullFileName%
    Goto :EOF

Similar Threads

  1. Replies: 2
    Last Post: 29-11-2011, 08:29 AM
  2. Need to append a sequential number to a date field in access
    By $Jaganmohini$ in forum Windows Software
    Replies: 4
    Last Post: 04-02-2011, 06:39 PM
  3. How can I append video files in powerpoint slides ?
    By Naotau in forum Windows Software
    Replies: 3
    Last Post: 26-11-2010, 03:22 AM
  4. Renaming files in Linux
    By Aileen_L in forum Operating Systems
    Replies: 5
    Last Post: 16-02-2010, 03:27 PM
  5. Renaming Music Files - working with ITunes Data Files
    By Tahseen Shahzad in forum Windows XP Support
    Replies: 2
    Last Post: 01-08-2009, 12:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •