DOS CMDs - For and Forfiles to rename files

  1.    22 Jan 2017 #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.
      My ComputerSystem Spec

  2. Kari's Avatar
    Posts : 15,151
    Windows 10 Pro
       22 Jan 2017 #2

    Landyman said: View Post
    Any suggestings would be most welcome.[/FONT][/FONT][/COLOR]
    My suggestion:

    I am normally one of those users who always ask why use a third party solution if Windows native tools can do the same job, but in this case I wholeheartedly recommend using Screenpresso, the best third party screenshot tool I have used.

    It names the screenshots almost as you'd prefer, naming them YYYY-MM-DD_HHhMM_SS.png (that red h is a letter h Screenpresso puts between HH and MM):

    Click image for larger version. 

Name:	image.png 
Views:	28 
Size:	191.3 KB 
ID:	118108

    It let's you freely modify keyboard shortcuts:

    Click image for larger version. 

Name:	image.png 
Views:	28 
Size:	36.5 KB 
ID:	118109

    The free version has some limitations but in all honesty I have not even noticed what the limitations are; all screenshots (and annotations in screenshots) in all my posts and tutorials are made with free version of Screenpresso. Here's a sample, a recent tutorial with several screenshots, annotated and clean: UUP to ISO - Create Bootable ISO from Windows 10 Build Upgrade Files

    (Filenames shown in my screenshots are not actual filenames created by Screenpresso because I use WYSIWYG editor when posting here, pasting screenshots directly in post from clipboard without uploading them first. This makes them all use a default name image.png when you check them here.)

    Download: Download | Screenpresso

      My ComputerSystem Spec

  3.    23 Jan 2017 #3

    Many thanks Kari. I've downloaded the program and it's user manual. A quick reading session indicates it will solve my problem and do much more.
      My ComputerSystem Spec

  4. Kari's Avatar
    Posts : 15,151
    Windows 10 Pro
       23 Jan 2017 #4

    You are welcome.

    As I said, I belong to those users who do not see a point in using third party solutions when Windows does it well with its native tools, but in case of screenshots I gave up: Screenpresso is a fabulous tool!
      My ComputerSystem Spec


Related Threads
I have renamed a macrium from its long chain of letters and numbers to simply D backup 010417. I read in another posting here that macrium sometimes will not restore a backup file that has been renamed. I'm trying to determine if this is in fact...
I am the administrator, but whenever i try to rename a file on the desktop it says "File Access Denied" and that i need to provide administrator permission to rename the file. How to fix it?
Quite frankly I'm surprised no one has brought this up (or I am using the wrong search terms). When copying files in explorer, Windows 7 (I can't remember anything older than that LOL) I am asked what I want to do with copying files that have the...
Batch Rename Deletes Files in Performance & Maintenance
Hey all, I just upgraded to Windows 10 last night, and I've been playing around with the new File Explorer. One thing I tried was the batch rename function (by which I mean just selecting multiple files and clicking "rename"). I quickly realized...
When I try to rename or delete a file Windows Explorer freezes for an average of 20 seconds. I opened my running processes to see what I could find, and during this 20 second period it reads "Not Responding" next to Windows explorer (as seen in...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 22:53.
Find Us