Not related to astronomy, but simple and usefull stuff.
My photo manager, ShotWell, stored all my photos in a /year/month/day/ tree. I wanted
all my photos to be stored by month only (/year/month/).
I have more than 8.000 photos (30 GB), so, I wrote a small script moving
all the files in the parent directory, in the recursive manner, removing all the
empty folders once the job done.
My script :
#!/bin/bash
# get all the full files names
find . -type f | while read -r file do
# for each file
# remove the file base name
folder=$(dirname "${file}")
# remove the folder name
subfolder=$(dirname "${folder}")
# move the file to the sub folder
mv "${file}" "${subfolder}"
done
# remove all the empty folders
find . -type d -empty -exec rmdir {} \;
It could help somebody...
Best regards !