I'm trying to sort my files by pattern into filename by creating Linux Script (Bash).
My files are mostly .JPG, some .AV and .MP4. I can't use meta tags, because this files have broken tags (restored from RAID crash).
Majority of my file are with tag like this Seaxxx_A01_xxx.jpg or Beach_xxx_A01A02_xxx.jpg or Mountain_xxx_A04A12_xxx.jpg (this is my reference for who took pics and device ie : camera, reflex, etc ...).
My need is to put file to the correct folder and subfolder, based on file name.
I've think achieve this task like this :
use find, look for pattern [A-Z][0-2][0-6] or [A-Z][0-2][0-6][A-Z][0-2][0-6], when this pattern is found, look for the first filename part, (ie Sea, beach, mountain, family, etc..., always placed as the first words, normaly I don't have anything other before) and use the first part to look for a folder with a similar name and put it on (if my file contain : Sea_Royan_xxx_A04A10_xxx.jpg and I have only a folder named "Sea" it must be placed into).
On each folder, subfolders are presents, like A01, A02, A03, A04 or Dio, Sandy, Mael, etc ... and I want the current found file (ie the same than the one used to placed into parent folder, Sea, mountain, etc...) be checked for the second pattern listed above be used to put on correct subfolder.
In fact and more siply I need : Look for files, when found, check filename and use two pattern to move it on the right folder and subfolders.
Let me know how I can do it (I know how look for files, based on pattern, but not how to read the current found filename and on this filename check for two pattern to be used as correct PATH), if you have a more easiest way or better way to do this feel free to let me know!
Sea_Royan_xxx_A04A10_xxx
if there's no directory namedSea
?