Search : in
By :

Rename file with datetime appended to filenam

Last answer on Jul 9, 2009 10:32:48 pm BST Betty, on Sep 24, 2008 6:15:21 pm BST 
 Report this message to moderators

Hello,

I have the following bat file:
FOR %%V IN (%1) DO FOR /F "tokens=1-5 delims=/: " %%J IN ("%%~tV") DO ECHO Rename "%%V" %%L%%J%%K_%%M%%N%%~xV

This will rename the files to the datetime stamp. However I want to append the datetime to the filename.
Example:
filename: betty.rpt rename to betty0924081530.rpt

Can you help me with the correct syntax?

Thanks, Betty

Configuration: Windows XP
Internet Explorer 6.0

Best answers for « Rename file with datetime appended to filenam » in :
Renaming multiple files in batch ShowRenaming multiple files in batch Native features Using a third-party program Renaming a large number of files can quickly become tedious. Fortunately, there are tools to automate this task in many cases: Native features On Windows...
Batch Script - Move files to \%date%\%time%\ ShowBatch Script - Move files to \%date%\%time%\ Issue Solution Note Issue I have been trying to make a simple batch script to create database backups and move then into a folder named by date, and a sub folder by time. This is what I...
[Vista] Take control over a file whose access is denied Show[Vista] Take control over a file whose access is denied Most Vista users have encounter the following type of message: "Access denied" when trying to edit some files or folder. To solve this problem: Right click the folder...
Download Lupas Rename ShowLupas Rename is a program allowing to rename several files at the same time. The features of this software : - To rename files or directories - To ename files in récursive sub-directories - Shell integration (right button on a folder) - To...
UNIX - Files ShowIntroduction to UNIX files In UNIX systems any element is represented in the form of a file. All files are architectured around a single tree structure where the base, called the root, is written "/". File types UNIX systems define different...
File sharing in Windows XP ShowAdvantages File sharing involves making the content of one or more directories available through the network. All Windows systems have standard devices making it easy to share the content of a directory. However, file sharing may lead to security...

1

gav, on Oct 10, 2008 11:46:43 pm BST
  • +2

Hi betty
i have a bat that can help u try this
set mm= %Date:~3,2%
set dd = %Date:~0,2%
set yy = %Date:~8,2%
pkzip -a AL%mm%dd%yy% *.doc

this zips all files in a folder and names it AL101008

Reply to gav

2

script-help, on Nov 18, 2008 10:49:27 pm GMT
  • +2

Is it possible to do a reverse?

For example

1) Rename 11-10-08-File1.TXT to File1.TXT
2) Rename 11-10-08-File2.TXT to File2.TXT

Reply to script-help

3

Sen, on Dec 17, 2008 8:33:05 pm GMT
  • +7

I have been using biterscripting a lot to do stuff like this from command mode.

Some sample code:

# Get the time stamp.
var str timestamp
set $timestamp=gettime()

# Get the file extension - after the last dot (assuming file name is in $file)
var str extension
stex "[^.^l"$ $file >$extn # ^.^ means find a dot, l means the last instance, [ means strip
# off everything beginning with the last dot.

# Add timestamp to the file name
set $file = $file + $timestamp

# Add back the extension
set $file = $file + $extension

# $timestamp has the format yyyymmddhhmmss . You can format it further. For example, if you just want the
# date (and no time), use the following
chex "8[" $timestamp > null # 8 means 8th character, [ means extract everything after the 8th char,
# >null means don't show the extracted content on screen.

etc.

Sen Hu

Reply to Sen

4

rebrov32, on Jan 17, 2009 8:34:21 pm GMT
  • +2

Try this free rename utility : http://jrename.free.fr

Reply to rebrov32

5

QSquared, on Jul 8, 2009 5:26:36 pm BST
  • +6

Set TDate=%date:~10,4%%date:~4,2%%date:~7,2%
FOR %%V IN (%1) DO Rename %%V %%V%TDate%

Reply to QSquared

6

 QSquared (Ben Personick), on Jul 9, 2009 10:32:48 pm BST
  • +1

Sorry first time I didn't fix the File extention, here I split everythgin out into simple steps, obviously you can combine several of these into one if you like. I hope you like it =) -Ben




:: Set the date to the format you desire once and store it as a variable
Set TDate=%date:~10,4%%date:~4,2%%date:~7,2%

::Start a Loop which goes to a subroutine through a 'call' function (This allow you to assign variables..
FOR %%V IN (%1) DO Call :DoLoop


::Start your complex processing inside this lable so that you can do as many lines as you line inside your loop
:DoLoop

:: Set Single-sided variable to double-sided variable
set OFullFileName=%%V

::Double-sided variable manipulation to get the original file's extention and name separated
Set OFileExt=%FileName:~-4%
Set OFileName=%OFullFileName:~0,-4%

::Build the completed new file Name from the variables already assigned
Set NFullFileName=%OFileName%%TDate%%OFileExt%

::Run your rename command
Rename %OFullFileName% %NFullFileName%

::Exit the sub routine, allowing you to continue your loop.
Goto :EOF

Reply to QSquared (Ben Personick)