Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing Date Modified?

149 views
Skip to first unread message

Terry Pinnell

unread,
Nov 26, 2020, 6:18:30 AM11/26/20
to
Is it possible to achieve the following with either a batch file or
command prompt on my Win 10 PC please? Or indeed any other hack, such as
a VBS script, etc?

Parent folders such as one named 'xyz' contain scores or hundreds of
subfolders. In each of these subfolders, such as one called 'abc', there
is a single file, called with the same name as its folder but extension
'.ino', such as abc.ino.

Usually that's the ONLY file. But, in case it proves relevant,
occasionally there may be one or more other files in that subfolder.
Even rarer one of those might be named xyz.txt, xyz.jpg, etc.

I want to process all of the *.ino files, from the top parent 'xyz'. I
don't care if the few files with other extensions get processed or not.

But here's the thing. Somehow the Date Modified entries for all the
subfolders containing the INO files have lost their original dates. The
INO files have retained them.

I want to automatically change all the subfolder Date Modified entries
to equal the Date Modified entry of its INO file of the same name.

Any help will be warmly appreciated please.

Terry

Terry Pinnell

unread,
Nov 26, 2020, 6:23:41 AM11/26/20
to
Wish there was a way to re-send this, correcting a typo spotted moments
later in an already complicated post!

Half way through, the line should be:

"Even rarer, one of those might be named abc.txt, abc.jpg, etc."

====================

JJ

unread,
Nov 27, 2020, 12:21:18 AM11/27/20
to
Because batch file alone doesn't provide any command to specifically change
file/folder date, and none of VBScript usable objects can change the date of
a folder (it's possible for file dates, but not for folder dates); the only
possible solution without downloading third party software is to use
PowerShell script. Pre Windows Vista system will still need to download
PowerShell seperately. Or compile either a VB.NET, C#, or JScript.NET
application; if .NET Framework (crap) is available.

Though IMO, I'd rather use third party software for changing folder date
(e.g. GNUWin's build of GNU's `touch`), considering the hassle of executing
PowerShell scripts, slow loading of PowerShell scripts (because it uses .NET
crap), and relatively large memory consumption.

Zaidy036

unread,
Nov 27, 2020, 10:41:21 AM11/27/20
to
Nirsoft has a program that might help. Look at
<https://www.nirsoft.net/utils/bulk_file_changer.html> Does not have to
be installed but runs from unzipped folder. It can be run with batch cmds.

Robert Roland

unread,
Nov 27, 2020, 12:59:17 PM11/27/20
to
On Thu, 26 Nov 2020 11:18:27 +0000, Terry Pinnell
<m...@somewhere.invalid> wrote:

>Is it possible to achieve the following with either a batch file or
>command prompt on my Win 10 PC please? Or indeed any other hack, such as
>a VBS script, etc?

Is PowerShell allowed?

>Somehow the Date Modified entries for all the
>subfolders containing the INO files have lost their original dates.

That is a feature. Take a look at this link for a possible explanation
and a generic solution: https://ss64.com/ps/syntax-lastmodified.html

>I want to automatically change all the subfolder Date Modified entries
>to equal the Date Modified entry of its INO file of the same name.

The following solution will process the INO file's parent folder
regardless of its name. Might be close enough?

The Windows File Explorer tends to keep folders open, in which case
the date cannot be set. Close all Explorer windows before you run the
script.

The script is wrapped so that it can be saved as a BAT file, which
makes it on-topic for this group. If you want, you can remove the
first line and save it as a PS1 file to make a normal PowerShell
script. The script lines are double spaced, so you can easily spot
line wraps. Edit the path to your preference, of course.


findstr /V "SomeRandomVeryUnlikelyText" %0|powershell -command -&goto
:EOF

$arduinoPath = "F:\test\arduino"

$fileList = Get-ChildItem -Path $arduinoPath -Filter "*.ino" -File
-Recurse

ForEach ($file in $fileList) {$file.Directory.LastWriteTime =
$file.LastWriteTime}

--
RoRo

Robert Roland

unread,
Nov 27, 2020, 1:08:39 PM11/27/20
to
On Fri, 27 Nov 2020 12:20:50 +0700, JJ <jj4p...@gmail.com> wrote:

>the hassle of executing
>PowerShell scripts,

Hassle? I don't notice any difference compared to batch files.

>slow loading of PowerShell scripts (because it uses .NET
>crap),

Loading time was slow, but that's a long time ago. Even on my Windows
8.1 system, PowerShell scripts launch without any noticable delay.
--
RoRo
0 new messages