Hi. I'm new. After some tricky register questions i'm finally here. My questions is short.
I want to create a folder structure with the filename of images. The structure should be like that:
/images/(A-Z structure)/websiteurl/(A-Z structure)/modelname/setname/image.png
Example: /images/P/picasa.web/M/Markus Heering/Wood Cutter/picasa.web-Markus Heering-Wood Cutter_023.png
The filename structure is like that: websiteurl-modelname-setname_imagenumber.extension
Example: picasa.web-Markus Heering-Wood Cutter_023.png
I already tried something with RegEx: ([\w]*.[\w]*)-([ \w]*)-([ \w]*)_([\d]{3}|[\w]{5}).([\w]*)
But i dont know how and where to set it. I failed quite hard. Here is my attempt: exiftool "-Directory<${Filename;s/([\w]*.[\w]*)-([ \w]*)-([ \w]*)_([\d]{3}|[\w]{5}).([\w]*)}" -d "DIR" -r -progress -v0
Files are getting moved but i don't know where :D
The original code i used: exiftool "-Directory<${Filename;s/([\w]*.[\w]*)-([ \w]*)-([ \w]*)_([\d]{3}|[\w]{5}).([\w]*)/$1\$2\$3/}" "W:\images" -r -progress -v0
The log is simple. No Error.
Hopefully someone can help me out. Please try to explain wat and how so i can try to understand what is going on. :)
Thanks!
The first command would fail because you don't finish the regex substitution.
\w is any word character and will fail to match the dot in picasa.web or the spaces.
I haven't tested it, but try this
"-Testname<W:/images/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$2/$1/\u$4/$3/$5/}/%F"
and if it works, use
"-Directory<W:/images/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$2/$1/\u$4/$3/$5/}"
This assumes that there won't be a dash in websiteurl or modelname, and there won't be an underscore in setname.
Also, for the missing files, check the current working directory. Since you didn't include a directory path, they were probably moved into the current directory. They won't stay on W:/images unless that is your current directory.
Quote from: StarGeek on June 09, 2019, 07:26:18 PM
The first command would fail because you don't finish the regex substitution.
\w is any word character and will fail to match the dot in picasa.web or the spaces.
I haven't tested it, but try this
"-Testname<W:/images/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$2/$1/\u$4/$3/$5/}/%F"
and if it works, use
"-Directory<W:/images/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$2/$1/\u$4/$3/$5/}"
This assumes that there won't be a dash in websiteurl or modelname, and there won't be an underscore in setname.
Also, for the missing files, check the current working directory. Since you didn't include a directory path, they were probably moved into the current directory. They won't stay on W:/images unless that is your current directory.
Thanks. For now it is creating the folders but it seems for each specific image it is creating a folder also not a folder structure.
Atleast i understood a bit more of the way to do it. I'm gonna show howit creates folder in folders. As i said it creates only folder on the W:\images.
There is also a syntax error for "Filename".
I got multipe images for one set so it wouldn't work quite well when i'm getting like 200 folders which are named after the image filename. :)
EDIT:
Well. I have done something silly...
exiftool "-Directory<W:/images/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$2/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/$1/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$4/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/$3/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/$5/}" "W:\images" -r -progress
But it works. :D
It is a mess for sure but if it works i don't care :D
Quote from: Jopo-JP on June 09, 2019, 08:05:28 PM
I got multipe images for one set so it wouldn't work quite well when i'm getting like 200 folders which are named after the image filename. :)
Just to verify, you were removing the
%F that I included in the first command?
The first command uses
TestName to test without writing. But it works like you were writing to
Filename, not
Directory. The second command removes the
%F so that you can properly move to a directory.
Quote from: StarGeek on June 09, 2019, 08:36:55 PM
Quote from: Jopo-JP on June 09, 2019, 08:05:28 PM
I got multipe images for one set so it wouldn't work quite well when i'm getting like 200 folders which are named after the image filename. :)
Just to verify, you were removing the %F that I included in the first command?
The first command uses TestName to test without writing. But it works like you were writing to Filename, not Directory. The second command removes the %F so that you can properly move to a directory.
Yeah. It is creating folders but too many. It creates a folder for each image.
Example: imagename: hello.com-this is-a test_001.jpg and hello.com-this is-a test_002.jpg
Its creates two folders with the specific image name with the exentsion so i get two folders with the name "hello.com-this is-a test_001.jpg" and "hello.com-this is-a test_002.jpg". The image is in there but not like:
hello.com/this is/a test/image_1.png
hello.com/this is/a test/image_2.png
Sorry for the filename just went into my head. I think the reason why it is doing it, is because the syntax error for "Filename".
Warning: syntax error for 'Filename'The messy methode isn't doing it because same code but i print only one group per folder. It should have the same error but it doesn't. I don't know why.
exiftool "-Directory<W:/images/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$2/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/$1/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/\u$4/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/$3/}/${Filename;s/^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*/$5/}" "W:\images" -r -progress
I think StarGeek's original command should work except that you need to change the delimiters for the regex because slashes are used in the expression:
"-Testname<W:/images/${Filename;s{^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*}{\u$2/$1/\u$4/$3/$5}}/%F"
> exiftool '-Testname<W:/images/${Filename;s{^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*}{\u$2/$1/\u$4/$3/$5}}/%F' tmp
'tmp/hello.com-this is-a test_001.jpg' --> 'W:/images/H/hello.com/T/this is/a test/hello.com-this is-a test_001.jpg'
1 directories scanned
0 image files updated
1 image files unchanged
In the session above I needed to use single quotes because I'm on a Mac. You would use double quotes on Windows. But I think the result is what you wanted.
- Phil
Quote from: Phil Harvey on June 12, 2019, 07:30:05 AM
I think StarGeek's original command should work except that you need to change the delimiters for the regex because slashes are used in the expression:
"-Testname<W:/images/${Filename;s{^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*}{\u$2/$1/\u$4/$3/$5}}/%F"
> exiftool '-Testname<W:/images/${Filename;s{^((.)[^-]*)-((.)[^-]*)-([^_]*)_.*}{\u$2/$1/\u$4/$3/$5}}/%F' tmp
'tmp/hello.com-this is-a test_001.jpg' --> 'W:/images/H/hello.com/T/this is/a test/hello.com-this is-a test_001.jpg'
1 directories scanned
0 image files updated
1 image files unchanged
In the session above I needed to use single quotes because I'm on a Mac. You would use double quotes on Windows. But I think the result is what you wanted.
- Phil
Thanks. Now it works. This helped me a lot. Also thanks to StarGeek to give me something to start.
Now moving stuff on GDrive via "rclone mount" will work smooth. Slow but it is working atleast so i can spend time somewhere else while whole gallery get sorted. Quite a lot of images i noticed. Thanks again.
I have just adjusted the RegEx so when a "-" is inside a webiste domain name it creates the correct folder also for every other element.
so if i have a photo of "hello-me.com" it will create the folder "hello-me.com" instead of "hello".
^([^_]*(.)[^-]*)-((.)[^-]*)-([^_]*)_.*