Discussion:
Create the following unusual folder from a container folder.
(too old to reply)
Terry Pinnell
2024-10-07 10:24:43 UTC
Permalink
This File Explorer folder (an example of a hundred or two on my Win 10
PC)

Loading Image...

is sorted by Date modified, most recent first. Each of its contents is
rather unusual: a single folder contain a single file of the same name,
such as _UsesDFR_available-e1.ino, BusyStateTesting.ino, etc.
(For the curious, these INO files open a text file, an Arduino program
in the IDE environment.)

I need to see my INO files in that same order. (Mainly to know which
Arduino program I edited last).
But I don't know how to do that, because the files are often dated
differently to the folders. So I can't just open the folder
'_UsesDFR_available-e1.ino' and expect that to be the most recent. As I
compose this, at about 07/10/24 10:30, its details are:

Loading Image...

Could a batch file achieve this? IOW, starting from the full path and
name of the container folder:
C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\MY
SKETCHES\DFR_MP3-All\DFR SD ORIG type\_BUSY-ETC

create a new folder containing all its INO files, extracted from their
individual parents?

Terry, UK
JJ
2024-10-08 04:31:54 UTC
Permalink
Post by Terry Pinnell
This File Explorer folder (an example of a hundred or two on my Win 10
PC)
https://www.dropbox.com/scl/fi/qtlfv5dm5wjxs720yj2aa/Sorting-INO-1.jpg?rlkey=iluo2zn1a6tov3anfp7emuzse&raw=1
is sorted by Date modified, most recent first. Each of its contents is
rather unusual: a single folder contain a single file of the same name,
such as _UsesDFR_available-e1.ino, BusyStateTesting.ino, etc.
(For the curious, these INO files open a text file, an Arduino program
in the IDE environment.)
I need to see my INO files in that same order. (Mainly to know which
Arduino program I edited last).
But I don't know how to do that, because the files are often dated
differently to the folders. So I can't just open the folder
'_UsesDFR_available-e1.ino' and expect that to be the most recent. As I
https://www.dropbox.com/scl/fi/mssae84bmfl9sh03jr4sg/Sorting-INO-2.jpg?rlkey=ckwox9wenhhf3x25ljss9l0rk&raw=1
Could a batch file achieve this? IOW, starting from the full path and
C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\MY
SKETCHES\DFR_MP3-All\DFR SD ORIG type\_BUSY-ETC
create a new folder containing all its INO files, extracted from their
individual parents?
Terry, UK
Use below batch file.

@echo off
setlocal

rem === CONFIG BEGIN

rem `DataDir` should point to the base folder which directly contains
rem subfolders, where those subfolders directly contains the .INO file.
set "DataDir=C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\MY
SKETCHES\DFR_MP3-All\DFR SD ORIG type\_BUSY-ETC"

rem `NewDirName` is the name of the new folder to be created directly
rem in the folder specified by above `DataDir`. e.g. if `DataDir` is
rem "e:\my files", and `NewDirName` is "123-pool"; the new folder would
rem be created as "e:\my files\123-pool"
set "NewDirName=123-pool"

rem === CONFIG END

pushd "%DataDir%"
if errorlevel 1 (
echo DataDir is not found or has invalid path.
pause
goto :eof
)

if not exist "%DataDir%\%NewDirName%" (
md "%DataDir%\%NewDirName%"
if errorlevel 1 (
echo Failed on creating a new folder in DataDir.
pause
goto :eof
)
)

set chk=0
for /d %%D in (*) do (
if exist "%%D\*.ino" (
set chk=1
echo %%~nxD
copy /y "%%D\*.ino" "%DataDir%\%NewDirName%"
)
)
echo [Done]
if %chk% == 0 (
echo No .INO file was found. DataDir seems pointing to the wrong folder.
)
pause
Terry Pinnell
2024-10-10 14:54:18 UTC
Permalink
Brilliant, thanks a bunch JJ, worked perfectly.

However, to my chagrin, I feel obliged to confess that I've discovered
my original assertion was wrong. All the tests I did this morning, with
care over choice of columns and their sort order, showed that the
Folders sorted by Date Modified **do** match the INO file dates after
all.

Very sorry therefore to have caused unnecessary work. However your BAT
is filed for possible future and/or learning.

Terry

--------------------
Post by JJ
Post by Terry Pinnell
This File Explorer folder (an example of a hundred or two on my Win 10
PC)
https://www.dropbox.com/scl/fi/qtlfv5dm5wjxs720yj2aa/Sorting-INO-1.jpg?rlkey=iluo2zn1a6tov3anfp7emuzse&raw=1
is sorted by Date modified, most recent first. Each of its contents is
rather unusual: a single folder contain a single file of the same name,
such as _UsesDFR_available-e1.ino, BusyStateTesting.ino, etc.
(For the curious, these INO files open a text file, an Arduino program
in the IDE environment.)
I need to see my INO files in that same order. (Mainly to know which
Arduino program I edited last).
But I don't know how to do that, because the files are often dated
differently to the folders. So I can't just open the folder
'_UsesDFR_available-e1.ino' and expect that to be the most recent. As I
https://www.dropbox.com/scl/fi/mssae84bmfl9sh03jr4sg/Sorting-INO-2.jpg?rlkey=ckwox9wenhhf3x25ljss9l0rk&raw=1
Could a batch file achieve this? IOW, starting from the full path and
C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\MY
SKETCHES\DFR_MP3-All\DFR SD ORIG type\_BUSY-ETC
create a new folder containing all its INO files, extracted from their
individual parents?
Terry, UK
Use below batch file.
@echo off
setlocal
rem === CONFIG BEGIN
rem `DataDir` should point to the base folder which directly contains
rem subfolders, where those subfolders directly contains the .INO file.
set "DataDir=C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\MY
SKETCHES\DFR_MP3-All\DFR SD ORIG type\_BUSY-ETC"
rem `NewDirName` is the name of the new folder to be created directly
rem in the folder specified by above `DataDir`. e.g. if `DataDir` is
rem "e:\my files", and `NewDirName` is "123-pool"; the new folder would
rem be created as "e:\my files\123-pool"
set "NewDirName=123-pool"
rem === CONFIG END
pushd "%DataDir%"
if errorlevel 1 (
echo DataDir is not found or has invalid path.
pause
goto :eof
)
if not exist "%DataDir%\%NewDirName%" (
md "%DataDir%\%NewDirName%"
if errorlevel 1 (
echo Failed on creating a new folder in DataDir.
pause
goto :eof
)
)
set chk=0
for /d %%D in (*) do (
if exist "%%D\*.ino" (
set chk=1
echo %%~nxD
copy /y "%%D\*.ino" "%DataDir%\%NewDirName%"
)
)
echo [Done]
if %chk% == 0 (
echo No .INO file was found. DataDir seems pointing to the wrong folder.
)
pause
Loading...