Hi all,
i have a folder, with tons of files containing as following,
on /my/folder/jobs/
some_name_2016-01-17-22-38-58_some name_0_0.zip.done
some_name_2016-01-17-22-40-30_some name_0_0.zip.done
some_name_2016-01-17-22-48-50_some name_0_0.zip.done
and these can be lots of similar files,
some_name_2016-01-18-22-40-30_some name_0_0.zip.done
some_name_2016-01-18-22-48-50_some name_0_0.zip.done
and i have also on the same folder tons of files containing, the same name, but the date and time changes, depending on the time and date it was done,
now as it is impossible to check if a file exist on that folder,
i would like to create a script that will do the following;
list all file with a specific date
create a folder with this specific date
move all files with this date to the new created folder,
and i need to do this for every different date.
i thought some thing like this, but not working at all, it work only if i specify the date, but i dont wont to do it manually, the script must understand what to do,
so here my script;
cd /my/folder/jobs/
files="2016-01-17"
newdir="2016-01-17/"
for i in {$files};
do
newdir=$(echo /my/folder/jobs/$newdir)
if ! [ -d $newdir ]; then
echo Directory $newdir does not exist. Creating $newdir.
mkdir -p $newdir;
fi
mv "*$files*" $newdir;
done
Thanks in advance for any suggestions.