File Info Output: Can I Restate Modification Date & Time?
Moderator: DosItHelp
File Info Output: Can I Restate Modification Date & Time?
I am working on a batch script that gives me a recursive list of all files in a folder. Each line presents multiple bits of information about one file, including (in this order) last modified date and time, file size in bytes, file name. Example of output: 04/03/2022 03:00 PM 265 Filename.
I would like to rearrange the date and time information so that a sort of the list will use dates correctly in ascending order. In other words, I would like to change that example to read something like 2022-04-03 15:00 265 Filename.
I have a little familiarity with batch use of DATE and TIME commands for this purpose. But that's not relevant here. In this case, I'm looking to modify the output of the file's modification date and time, not the current system date and time. I'm not sure I have seen that done, and that's my question: is it feasible and, if so, where should I be looking for guidance in the appropriate syntax?
As an alternative, it is not terribly difficult to modify the list after the fact, in a spreadsheet. I am just hoping to automate the process in the batch command if that's possible.
I would like to rearrange the date and time information so that a sort of the list will use dates correctly in ascending order. In other words, I would like to change that example to read something like 2022-04-03 15:00 265 Filename.
I have a little familiarity with batch use of DATE and TIME commands for this purpose. But that's not relevant here. In this case, I'm looking to modify the output of the file's modification date and time, not the current system date and time. I'm not sure I have seen that done, and that's my question: is it feasible and, if so, where should I be looking for guidance in the appropriate syntax?
As an alternative, it is not terribly difficult to modify the list after the fact, in a spreadsheet. I am just hoping to automate the process in the batch command if that's possible.
Re: File Info Output: Can I Restate Modification Date & Time?
Could you elaborate on how you currently generate this output?
Steffen
Steffen
Re: File Info Output: Can I Restate Modification Date & Time?
Yes. Thanks for asking. My post provides a writeup, with links to the sources that explained it to me. That post is at https://raywoodcockslatest.wordpress.co ... h-oneline/. (Sorry for the long URL. Unfortunately, the FAQs provide no guidance in using the link button in this composition window, nor any link to the guide that supposedly exists somewhere on this site.)
The key lines of code, generating the output, are as follows:
So that's where the output is coming from.
The key lines of code, generating the output, are as follows:
Code: Select all
for /r %%A in (*) do (
for /f %%B in ('certutil -hashfile "%%A" SHA512 ^| find /V ":"') do echo %%~tA %%~zA %%B %%~fA >>%OUTFILE%
)
Re: File Info Output: Can I Restate Modification Date & Time?
First option: replace "/" with "-" in the output file (looks like this character is in the date only).
Second option: rearange %%~tA to YYYY-MM-DD separately.
Saso
Second option: rearange %%~tA to YYYY-MM-DD separately.
Saso
Re: File Info Output: Can I Restate Modification Date & Time?
Thanks. I suspected that would be the solution.
I asked because, well, I had a friend who knew APL. In APL, you could launch a rocket to the Moon with a command that looked like ΦP→W?. Every now and then I see a bit of batch code that reminds me of that, where they do things I didn't know were possible.
Is it just me, or is there a lot less of that batch mastery these days? As I think of it, it's been a while since I saw much of it.
I asked because, well, I had a friend who knew APL. In APL, you could launch a rocket to the Moon with a command that looked like ΦP→W?. Every now and then I see a bit of batch code that reminds me of that, where they do things I didn't know were possible.
Is it just me, or is there a lot less of that batch mastery these days? As I think of it, it's been a while since I saw much of it.
Re: File Info Output: Can I Restate Modification Date & Time?
Whoa Apparently I totally lost track of this thread, sorry.
Steffen
I'm under the same impression. Batch is going to get kicked out by PowerShell.Is it just me, or is there a lot less of that batch mastery these days? As I think of it, it's been a while since I saw much of it.
Steffen
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: File Info Output: Can I Restate Modification Date & Time?
It's definitely moved to more of a hobby language from what I've seen, but there are still a couple of fairly active communities on Reddit and Discord.
Re: File Info Output: Can I Restate Modification Date & Time?
Thanks for your feedback.
Early dabbling suggests you have to learn all of PowerShell to be sure you're using it correctly for anything. I've had several experiences of using scripts people recommended, only to find there's an exception requiring the additional WhoZit cmdlet if you wear a size 12 shoe.
For my purposes, Python is a more likely choice. It can actually teach me to start with "Hello, World!"
Take care ...
Early dabbling suggests you have to learn all of PowerShell to be sure you're using it correctly for anything. I've had several experiences of using scripts people recommended, only to find there's an exception requiring the additional WhoZit cmdlet if you wear a size 12 shoe.
For my purposes, Python is a more likely choice. It can actually teach me to start with "Hello, World!"
Take care ...