Windows 10: DOS CMDs - For and Forfiles to rename files

Discus and support DOS CMDs - For and Forfiles to rename files in Windows 10 Support to solve the problem; 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.... Discussion in 'Windows 10 Support' started by Landyman, Jan 21, 2017.

  1. Landyman Win User

    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.

    :)
     
    Landyman, Jan 21, 2017
    #1
  2. Rohn007 Win User

    Batch rename files using ForFiles command getting syntax error

    Win 10

    I want to rename a bunch of files to add a prefix. ie "aaa.url" to "win 10- aaa.url"

    I found these pages:

    Rename file extensions in bulk, including files in subfolders

    Forfiles

    the example and my version of the command

    forfiles /M *.jpg /C "cmd /c rename @file \"@fname - pic.jpg\""

    forfiles /M *.* /C "CMD /c RENAME @FILE \"WIN 10- @FILE\""

    I get this output:

    D:\Public\Favorites\@test>forfiles /M *.* /C "CMD /c RENAME @FILE \"WIN 10- @FILE\""

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    'Tutorials' is not recognized as an internal or external command,

    operable program or batch file.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    As far as I can see I have the syntax OK, but obviously windows does not agree with me.

    What am I missing?
     
    Rohn007, Jan 21, 2017
    #2
  3. Windows and CMD- renaming a file in CMD

    The error code reads

    Stop Code NTSF Stop File System

    There is no Numbers other than a statement to show this message to the repair man?? please advise.

    In the meantime I will follow you links you provided

    Randy
     
    RandallBrock, Jan 21, 2017
    #3
  4. Kari Win User

    DOS CMDs - For and Forfiles to rename files

    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):


    DOS CMDs - For and Forfiles to rename files [​IMG]

    It let's you freely modify keyboard shortcuts:


    DOS CMDs - For and Forfiles to rename files [​IMG]

    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
     
  5. Landyman Win User
    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.
     
    Landyman, Jan 23, 2017
    #5
  6. Kari Win User
    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!
     
    Kari, Apr 4, 2018
    #6
Thema:

DOS CMDs - For and Forfiles to rename files

Loading...
  1. DOS CMDs - For and Forfiles to rename files - Similar Threads - DOS CMDs Forfiles

  2. Help me to get the MS-DOS cmds to copy tar.gz files from source to destination in a loop manner

    in Windows 10 Gaming
    Help me to get the MS-DOS cmds to copy tar.gz files from source to destination in a loop manner: Can anyone please help me to get the MS-DOS cmds to copy tar.gz files from source to destination in a loop manner.If it exists in destination folder then1. Delete it from destination2. Copy the file from source to destinationIf it does not exist in destination folder then1....
  3. Help me to get the MS-DOS cmds to copy tar.gz files from source to destination in a loop manner

    in Windows 10 Software and Apps
    Help me to get the MS-DOS cmds to copy tar.gz files from source to destination in a loop manner: Can anyone please help me to get the MS-DOS cmds to copy tar.gz files from source to destination in a loop manner.If it exists in destination folder then1. Delete it from destination2. Copy the file from source to destinationIf it does not exist in destination folder then1....
  4. Help using Forfiles command

    in Windows 10 Network and Sharing
    Help using Forfiles command: Hello everyone, I am having a syntax error when executing my forfiles command. My proposal is to develop a .bat script to everyday copy the last file backup from a folder to the one drive folder located in another drive "K" This is the command I am using forfiles...
  5. Forfiles Error Invalid Agrument

    in Windows 10 Customization
    Forfiles Error Invalid Agrument: Not sure why return error Invalid Agrument Some one can see the issue. Thank you. forfiles /p C:\Program Files\MicrosoftSQLServer\MSSQL15.SQL\MSSQL\Backup\ -s -m *.bak /D -2 /C "cmd /c del /q @path"...
  6. Renaming a file

    in AntiVirus, Firewalls and System Security
    Renaming a file: Just had a "bios" update on HP computer and now I cannot rename a file without getting the message " Don't have permission to save in this locatin. Contact the administrator to obtain permission. I AM THE ADMINISTRATOR AND ONLY USER! How is this fixed … please?...
  7. Weir execution cmds

    in Windows 10 Network and Sharing
    Weir execution cmds: What are whoami.exe wextract.exe, and userinit.exe? https://answers.microsoft.com/en-us/windows/forum/all/weir-execution-cmds/3116953c-5e9f-42d6-9eb2-9fa3d58c5739"
  8. Forfiles error

    in Windows 10 Customization
    Forfiles error: I am running Windows 10 and upon startup I am getting a notification titled C:\WINDOWS\system32\forfiles.EXE...sometimes it loads Errors and other times it remains blank. My computer performance does not seem to be impacted. Can anyone advise?...
  9. DOS files in Win10

    in Windows 10 Installation and Upgrade
    DOS files in Win10: I recently found a post by John Shadow regarding selective backing up via a dos file he had written. I would like to apply this to my win10 but as a newbie, I do not know how to implement it. I have written it out as suggested in notepad but do not know how to get it to...
  10. Explorer is missing almost ALL FILE CMDS to: RENAME, DELETE.....

    in Windows 10 Support
    Explorer is missing almost ALL FILE CMDS to: RENAME, DELETE.....: previous versions of windows. Can I ADD things like RENAME commands to the RIGHT CLICK? 88953

Users found this page by searching for:

  1. use forfiles to rename a file to add date

    ,
  2. cmd forfiles rename to add modified date

    ,
  3. adding date to file name in windows10 dos using forfiles

    ,
  4. FORFILES p last windows