Page 1 of 1
File Info Output: Can I Restate Modification Date & Time?
Posted: 03 Apr 2022 14:48
by raywood
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.
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 04 Apr 2022 11:16
by aGerman
Could you elaborate on how you currently generate this output?
Steffen
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 05 Apr 2022 19:24
by raywood
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:
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%
)
So that's where the output is coming from.
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 09 Apr 2022 09:55
by raywood
Bump
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 09 Apr 2022 10:14
by miskox
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
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 16 May 2022 09:01
by raywood
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.
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 16 May 2022 10:02
by aGerman
Whoa
Apparently I totally lost track of this thread, sorry.
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'm under the same impression. Batch is going to get kicked out by PowerShell.
Steffen
Re: File Info Output: Can I Restate Modification Date & Time?
Posted: 16 May 2022 12:22
by ShadowThief
raywood wrote: ↑16 May 2022 09:01
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.
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?
Posted: 01 Jun 2022 18:59
by raywood
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 ...