Discussion:
Changing Date Modified?
(too old to reply)
Terry Pinnell
2020-11-26 11:18:27 UTC
Permalink
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
2020-11-26 11:23:39 UTC
Permalink
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."

====================
Post by Terry Pinnell
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
JJ
2020-11-27 05:20:50 UTC
Permalink
Post by Terry Pinnell
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
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.
Robert Roland
2020-11-27 18:08:37 UTC
Permalink
Post by JJ
the hassle of executing
PowerShell scripts,
Hassle? I don't notice any difference compared to batch files.
Post by JJ
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
Zaidy036
2020-11-27 15:41:18 UTC
Permalink
Post by Terry Pinnell
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
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
2020-11-27 17:59:15 UTC
Permalink
On Thu, 26 Nov 2020 11:18:27 +0000, Terry Pinnell
Post by Terry Pinnell
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?
Post by Terry Pinnell
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
Post by Terry Pinnell
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
Loading...