I need to copy around 40.0000 files into date structured folders.
example file:
/var/public/voicelogging/quality_monitoring/20151209/bbbbbb_I_20151209-185841_xxxxxx_12434_89343.WAV
Is one of the many files I need to copy to /home/username/logging/
The file name has 2 variables in it that I need to use:
bbbbbb_I_20151209-185841_xxxxxx_12434_89343.WAV
20151209
is of course the date
12434
is the id of the user who made the file.
What I need is a script/one liner that can search in a dir for the user id.
Then create a dir with the user id in /home/username/logging
.
After it created the folder it needs to create a dir for every date it can find.
And place every file in to the right userid/date
directory.
example of result dir.
/home/username/logging/12434/20151209/bbbbbb_I_20151209-185841_xxxxxx_12434_89343.WAV
I have build a one-liner for making the date dir's , but I still need to make the user id dir myself.
find /var/public/voicelogging/quality_monitoring/ -type f -name "*12434*" | sed -r 's/^.{65}//' | cut -c1-8 | xargs -I {} mkdir {} /home/username/logging/12434
How can I copy the right file to the right place?
WAV
? Are all directory names right under...quality_monitoring/
dates or are there other dir names that are not dates ?