StampMe.cmd

Greetings! We are one of the oldest mod sites on the Interwebs. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation by sending Inxide points.
  • Post: Give Inxide your thoughts on this Script.
  • Vote: Help Inxide win the Monthly Awards.
  • Rate: Give this Script a rating out of 10.
  • Flag: Alert moderators and warn members of a problem with this Script.
  • Watch: Get notified when this Script is updated.
Mascot

Interested?

Sign up

Already a Bananite? Login

31 lines | 3 kb | Raw Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@ECHO off SETLOCAL IF [%1] NEQ [] goto s_start

:: Author - Simon Sheppard, Nov 2012 :: Tested for Windows XP, Windows 2008 Echo StampMe.cmd Echo Rename a file with the DATE/Time Echo: Echo Syntax Echo STAMPME TestFile.txt Echo: Echo STAMPME "Test File.txt" Echo: Echo STAMPME "c:\docs\Test File.txt" Echo: Echo Will rename the file in the format "Test File-2009-12-30@16-55.txt" Echo: Echo In a batch file use CALL STAMPME ... GOTO :eof

:s_start Set _file=%~n1% Set _pathname=%~f1% Set _ext=%~x1%

::Get the date For /f "tokens=1-4 delims=/-. " %%G in ('Date /t') Do (Call :s_fixdate %%G %%H %%I %%J) Goto :s_time

:s_fixdate Set _yr=%1 if "%_yr:~0,1%" GTR "9" Shift For /f "skip=1 tokens=2-4 delims=(-)" %%G in ('Echo.^|Date') Do ( Set %%G=%1&Set %%H=%2&Set %%I=%3) goto :eof

:s_time :: Get the time For /f "tokens=1-3 delims=1234567890 " %%a in ("%time%") Do Set "delims=%%a%%b%%c" For /f "tokens=1-4 delims=%delims%" %%G in ("%time%") Do ( Set _hh=%%G Set _min=%%H Set _ss=%%I Set _ms=%%J ) :: Strip any leading spaces Set _hh=%_hh: =%

:: Ensure the hours have a leading zero if 1%_hh% LSS 20 Set _hh=0%_hh%

Echo Year-Month-Day@Hour-Min-Sec Echo %yy%-%mm%-%dd% @ %_hh%-%_min%-%_ss% REN "%_pathname%" "%_file%-%yy%-%mm%-%dd%@%_hh%-%_min%-%_ss%%_ext%"Rename a file (or folder) by appending the current date and time to the existing filename:

@ECHO off SETLOCAL IF [%1] NEQ [] goto s_start

:: Author - Simon Sheppard, Nov 2012 :: Tested for Windows XP, Windows 2008 Echo StampMe.cmd Echo Rename a file with the DATE/Time Echo: Echo Syntax Echo STAMPME TestFile.txt Echo: Echo STAMPME "Test File.txt" Echo: Echo STAMPME "c:\docs\Test File.txt" Echo: Echo Will rename the file in the format "Test File-2009-12-30@16-55.txt" Echo: Echo In a batch file use CALL STAMPME ... GOTO :eof

:s_start Set _file=%~n1% Set _pathname=%~f1% Set _ext=%~x1%

::Get the date For /f "tokens=1-4 delims=/-. " %%G in ('Date /t') Do (Call :s_fixdate %%G %%H %%I %%J) Goto :s_time

:s_fixdate Set _yr=%1 if "%_yr:~0,1%" GTR "9" Shift For /f "skip=1 tokens=2-4 delims=(-)" %%G in ('Echo.^|Date') Do ( Set %%G=%1&Set %%H=%2&Set %%I=%3) goto :eof

:s_time :: Get the time For /f "tokens=1-3 delims=1234567890 " %%a in ("%time%") Do Set "delims=%%a%%b%%c" For /f "tokens=1-4 delims=%delims%" %%G in ("%time%") Do ( Set _hh=%%G Set _min=%%H Set _ss=%%I Set _ms=%%J ) :: Strip any leading spaces Set _hh=%_hh: =%

:: Ensure the hours have a leading zero if 1%_hh% LSS 20 Set _hh=0%_hh%

Echo Year-Month-Day@Hour-Min-Sec Echo %yy%-%mm%-%dd% @ %_hh%-%_min%-%_ss% REN "%_pathname%" "%_file%-%yy%-%mm%-%dd%@%_hh%-%_min%-%_ss%%_ext%"
Rename a file (or folder) by appending the current date and time to the existing filename. For more information, _[Click Here.](http://ss64.com/nt/syntax-stampme.html "Here")_

Posts

None found

Share

Shareable Image:
Share banner
HTML embed code:
BB embed code:
Markdown embed code:

More embeddable images

Bookmark and Share

Credits

Original Authors
Simon Sheppard

Submitter

Inxide avatar
Inxide avatar Offline
Inxide Studio Flag Affiliation: Inxide Studio
Member Joined 4y
120 points Ranked 25582nd

Inxide avatar
Inxide
Inxide Studio Flag
Inxide Studio

Redistributor
Are you the owner? Request Ownership
Send a Private Message to the submitter

Category

Stats

Posts
0
Views
2,069
Date Added
4y
bcp.crwdcntrl.net tracking pixel