I hava a ROOT folder that contains multiple subfolders
Every subfolder contains a common folder with the following name 'data' and multiple csv files inside.
I would like to setup an script that perform the following actions:
Loop into every 'data' folder located in every subfolder at ROOT folder
Retain only files modified in the last 24 hours and move the rest of files into an archive folder named 'archive' located in the same path of ROOT\sub1, ROOT\sub, etc...
If one of the 'archive' folder doesn't exist in one of the subfolder the script should create the archive folder
Extra bonus requirement (if possible): based on the datelastmodified of old files, the script should create a date folder 'dd-mm-yyy' into every archive folder and move the files into respectively
Log files should be named as followed: 'log-archive-files' and should be generated at the same path in which the script is launched
if ROOT folder doesn't exist log output should be: Now & ROOT doesn't exist
If one of the sub folders does't contain data folder log output should be: NOW sub folder path doesn't contains files unable to move files
file.count =0 of one of the data folder is empty log output should be: NOW sub folder path is empty
If no error log output should be: NOW files have been successfully moved
Thank you in advance for your help.