Created
October 15, 2013 14:38
-
-
Save aembleton/6992585 to your computer and use it in GitHub Desktop.
Renames files that have a name ending in 20131015-140115.csv to the current date in the format yyyyMMdd then a -, then the number already in the file name, incremented by 1. File ending in 20131015-140115.csv ran through this script on 1 January 2014 will have their ending renamed as 20130101-140116.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
set FOLDER_PATH=. | |
set year=%date:~-4% | |
set month=%date:~3,2% | |
set day=%date:~0,2% | |
pushd %FOLDER_PATH% | |
for %%f in (*csv) do if %%f neq %~nx0 ( | |
set "filename=%%~nf" | |
set "postfix=!filename:~-6!" | |
set /a postfix=postfix+1 | |
set "filename=!filename:~0,-15!" | |
ren "%%f" "!filename!!year!!month!!day!-!postfix!%%~xf" | |
) | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment