When I cat the file which I've generated with this:
IFS=$'\n'
while read i
do printf "%s " "$i"
stat --format=%Z $i
done < <(/bin/find /data/owncloud/*/files -type f -not -path "/data/owncloud/sds/*" -not -name "ownCloud Manual.pdf") > /root/script/newpurge/filelistwithchangeddate
There is a line like this:
/data/owncloud/ksdfl/files/GIA - AGP/12 Samples/738617 sdds Hotel/Thumbs.db
However if I list this file it actually has 2 spaces in the name like this:
/data/owncloud/ksdfl/files/GIA\ -\ AGP/12\ Samples/738617\ \ sdds\ Hotel/Thumbs.db
And when the move/delete part is running it doesn't move these files with double spaces. This is the rest part of the script:
# epoch date 30 days earlier than today
filetodelete=$(expr `date +'%s'` - 2592000)
# Files older than 30 days
/bin/awk -v epoch="$filetodelete" '$NF<epoch' /root/script/newpurge/filelistwithchangeddate > /root/script/newpurge/oldfiles
/bin/awk '{$NF=""}1' /root/script/newpurge/oldfiles > /root/script/newpurge/marktodelete
sed -i "s/[ ]\+$//g" /root/script/newpurge/marktodelete
today=$(date +%Y%m%d)
mkdir /data/willbedeleted/$today
cp -pr /root/script/newpurge/marktodelete /data/willbedeleted/$today/
while IFS= read -r i; do
mv -- "$i" /data/willbedeleted/$today/
done < /root/script/newpurge/marktodelete
Where is the issue?