2

I'm looking to get a file's last modified date from

C:\Program Files (x86)\FolderTransfer4\WRTEUHH.dll

I used script

for %a in (WRTEUHH.dll) do set FileDate=%~ta

which posted here: How to get file's last modified date on Windows command line?

This script works. However, this only works if that DLL is in the same folder where command prompt ran from. I would like to get it from that program files folder and the date from there directly if possible.

Community
  • 1
  • 1
Sam
  • 45
  • 1
  • 1
  • 5

2 Answers2

3

Here are a few examples for you:

Last Written Date and Time - (cmd.exe) using provided example with for variable reference expansion

FOR %A IN ("%ProgramFiles(x86)%\FolderTransfer4\WRTEUHH.dll") DO @ECHO=%~tA

Last Written Date and Time - (cmd.exe) using where command in for loop, (does not cater for local time outputs using AM/PM notation)

FOR /F "TOKENS=2-3" %A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @ECHO=%A %B

Last Written Date only - (cmd.exe) using where command in for loop

FOR /F "TOKENS=2" %A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @ECHO=%A

Last Written Date and Time - (batch file) using provided example with for variable reference expansion

@FOR %%A IN ("%ProgramFiles(x86)%\FolderTransfer4\WRTEUHH.dll") DO @(ECHO=%%~tA&PAUSE)

Last Written Date and Time - (batch file) using where command in for loop, (does not cater for local time outputs using AM/PM notation)

@FOR /F "TOKENS=2-3" %%A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @(ECHO=%%A %%B&PAUSE)

Last Written Date only - (batch file) using where command in for loop

@FOR /F "TOKENS=2" %%A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @(ECHO=%%A&@PAUSE)
Mofi
  • 46,139
  • 17
  • 80
  • 143
Compo
  • 36,585
  • 5
  • 27
  • 39
  • Oh wow. Thank you so much. I ended up using the first script which worked perfectly for me. Thank you so much for the details. – Sam Oct 27 '16 at 14:38
2

I've used the forfiles command in the past which worked pretty well and it may help in this case.

Here's an example and output:

Command forfiles /P C:\_Demo\WritersForum /M *.* /C "cmd /c echo @file @fdate @ftime"

Output "06-21-09-20__Broken_links.txt" 6/21/2016 9:21:08 AM "06-21-09-21__Broken_links.txt" 6/21/2016 9:22:06 AM "10-20-04-23__Broken_links.txt" 10/20/2016 4:24:00 PM "10-20-04-25__Broken_links.txt" 10/20/2016 4:25:57 PM "10-20-04-26__Broken_links.txt" 10/20/2016 4:26:57 PM

If this doesn't work I should be able to help out with the script above.

JWarren
  • 49
  • 2
  • 6
  • 1
    Part of my response was left off. You can use the /S switch to recurse. The /P switch is the path so you'll just need to change that to program files (x86). – JWarren Oct 26 '16 at 21:34