Script to create list of folder names based on data change

August 17, 2020 at 03:36:57
Specs: Windows 10
Hello there, need some help. Been using the following script to create a list of folder names that are in order of most recently modified but I've been made aware that the parent folder doesn't always update the modified date when daughter folders have things modified in them. this is understandably annoying as not everything is getting backed up as a result. is there a way to have it so they list is created based on whether the volume of data has changed compared with the prior day/ hour ect.

Original script:
@echo off & setlocal
set file="M:\__Test\Z.txt"
(for /f "tokens=1* delims=[]" %%a in ('dir /b /o-d Z:\ ^|find /n /v ""') do (
if %%a gtr 10 goto :eof
echo %%b
)
) > %file%


See More: Script to create list of folder names based on data change


#1
August 17, 2020 at 05:34:35
Hope this what you want as code :

Remark : I tested this batch file with a folder E:\Test so don't forget to change to yours !
I added the switch /AD to select only folder.

@echo off 
@for /f "tokens=1* delims=[]" %%a in ('dir /b /AD /o-d E:\Test ^|find /n /v ""') do (
	echo %%b
)
pause


Reply ↓  Report •

#2
August 17, 2020 at 08:46:54
No sorry, i need the
set file="M:\__Test\MatthewR\Z.txt"

if %%a gtr 25 goto :eof
echo %%b

as that tell the script where to create the file


Reply ↓  Report •

#3
August 17, 2020 at 21:14:55
Possibly using attrib? First, from "root": attrib -a *.* /s
This clears all A (archive-bit) from all files in descending subdirs.
Subsequently, from root: dir /b /aa /s *.*
will give you list of all files changed since previous backup. After backup, then clear the
'A' attribute as per step one.
Xcopy also handles this using /A and /L options to get a listing, or /M option if you want it to do the backup and clear the 'A' in one step.
A file's size doesn't always indicate a change in content, (although rarely content can change and size not). Truly anal and only guaranteed method would be using fsum to prove a file is changed or not, but for most purposes, that's not necessary.

message edited by nbrane


Reply ↓  Report •
Related Solutions


Ask Question