Page 1 of 1

[SOLVED] file rename to date and time created

Posted: 22 Dec 2015 00:47
by buffyiscool
Hi All.

After quite a bit of searching various sites I am still at a loss regarding this problem.

I have a security camera which records its feed as 30 minute segments using a filename format of
***.***.*.***-00-hhmmss (***.***.*.*** = ip address of camera)

I would like to batch rename the files using the file creation date as follows
dd.mm.yyyy-hhmm

All of the solutions I have come across on the Internet are for either appending the date or time and start off simple but then escalate into code that would probably fill a book.

Any help with this would be really appreciated.

Thanks
Colin

Re: file rename to date and time created

Posted: 22 Dec 2015 04:08
by foxidrive
buffyiscool wrote:I have a security camera which records its feed as 30 minute segments using a filename format of
***.***.*.***-00-hhmmss (***.***.*.*** = ip address of camera)

I would like to batch rename the files using the file creation date as follows
dd.mm.yyyy-hhmm


Colin, What OS version are you using?
Do you have restrictions on the tools you want to use?

Run this in the folder and shows us some screen output - the format is important.

Code: Select all

@echo off
for %%a in (*.*) do echo %%~ta
pause

Re: file rename to date and time created

Posted: 22 Dec 2015 05:50
by buffyiscool
Hi foxidrive

Thanks for the reply.

I am using Windows 7 OS. Ideally my request would be just code that I could add to an existing batch file which currently changes the extension from .264 to .mpeg.

I ran the code you provided in one of the folders and also took a screenshot of the folder so you could see the original filename format.

Image

Hope you can see the image above.

Once again thanks.
Colin

Re: file rename to date and time created

Posted: 22 Dec 2015 07:42
by Squashman
You can copy and paste from the CMD prompt. Please do so.

Re: file rename to date and time created

Posted: 22 Dec 2015 08:30
by buffyiscool
This is the output from the previous code posted.

Code: Select all

22/12/2015 00:54
22/12/2015 01:24
22/12/2015 01:54
22/12/2015 02:24
22/12/2015 02:54
22/12/2015 03:24
22/12/2015 03:54
22/12/2015 04:24
22/12/2015 04:54
22/12/2015 05:24
22/12/2015 05:45
21/12/2015 21:54
21/12/2015 22:24
21/12/2015 22:54
21/12/2015 23:24
21/12/2015 23:54
22/12/2015 00:24
22/12/2015 11:37
Press any key to continue . . .

Re: file rename to date and time created

Posted: 23 Dec 2015 05:20
by buffyiscool
Hi All

Just to say thanks for all the help I received on this topic.

I have managed to do what I wanted by creating a small vb.net program.

Thanks again. Merry Christmas and all the best for 2016.

Colin

Re: file rename to date and time created

Posted: 23 Dec 2015 13:09
by foxidrive
buffyiscool wrote:I have managed to do what I wanted by creating a small vb.net program.


Excellent. I was waylaid and forgot to return. Sorry.

Thanks again. Merry Christmas and all the best for 2016.

Colin


All the best to you, also. Cheers.

Re: file rename to date and time created

Posted: 23 Dec 2015 13:13
by foxidrive
buffyiscool wrote:This is the output from the previous code posted.

Code: Select all

22/12/2015 00:54
Press any key to continue . . .


This code should rename the files as you've requested. Test it in a folder of copies first.

Code: Select all

@echo off
for %%a in (*-*-*) do for /f "tokens=1-5 delims=/: " %%b in ("%%~ta") do ren "%%a" "%%b.%%c.%%d-%%e%%f"

Re: file rename to date and time created

Posted: 23 Dec 2015 23:01
by thefeduke
foxidrive wrote:

Code: Select all

for %%a in (*-*-*) do for /f "delims=/: " %%b in ("%%~ta") do ren "%%a" "%%b.%%c.%%d-%%e%%f"
Replacing

Code: Select all

"delims=/: "
with

Code: Select all

"tokens=1-5* delims=/: "
should help.
John A.

Re: [SOLVED] file rename to date and time created

Posted: 24 Dec 2015 01:56
by buffyiscool
For those interested here is a screenshot of the vb.net program I created to perform the required task.

Image

If image does not show you can view it here: https://www.dropbox.com/s/6tgnvsx4ez2jr ... e.jpg?dl=0

Once again thanks for all the help.

Colin

Re: file rename to date and time created

Posted: 24 Dec 2015 02:48
by foxidrive
thefeduke wrote:

Code: Select all

"tokens=1-5* delims=/: "
should help.
John A.



Thank you John, it certainly requires the tokens. Colin's task doesn't have extensions so I didn't add code for it - why would you when it's not in the job description. :D