New
#1
DOS CMDs - For and Forfiles to rename files
I have just bought a Surface 4 Pro with k'brd. I find that one old program will no longer run correctly, so need to make a Batch file to replace it.
Windows 10 screen capture produces files all with the same name, appending a serial number.
Capture.exe produces a .bmp file with the date/time in the file name. I wish to do this.
I've investigated the FOR and FORFILES CMDs, but so far no success.
This code will get the system date:-
:: Get the date/time
FOR /f %%a in ('WMIC OS GETLocalDateTime ^| find "."') DO Set _DTS=%%a
Set _datetime=%_DTS:~0,4%-%_DTS:~4,2%-%_DTS:~6,2%@%_DTS:~8,2%-%_DTS:~10,2%-%_DTS:~12,2%
Echo Year-MM-Day@HR-Min-Sec
Echo %_datetime%
This code with FORFILES will get the file's parameters:-
@file – Name of the file(includes extension)
@fname – Name of the file excluding extension @Ext – Extension of the file
@fdate – Last modified date of the file
@ftime – Last modified time of the file
However I can't get them to work together.
W 10 stores screen dumps (<Win> + <PrtScn>) in a folder, 'Screenshots', under 'C:\Users\myname\Pictures\'.
A file could be: 'Screenshot (5).png with a UK date of 18/01/2017 21:33
I want to rename this file:- 'Cap_170118_213315.png'. I've included the seconds, as this is very important and used a 2 digit year as YYMMDD_HHMMss.
Any suggestings would be most welcome.