Hi Team,
Can you suggest sub-folder creation as below:
https://www.theabc.com/constantfolder/folder-xyz/
where
https://www.theabc.com/constantfolder/
is fixed and
folder-xyz
changes.
Basically, want to save images under multiple sub-folders under /constantfolder/ based on each sub-folder name.
Help on Subfolder creation
-
- Site Admin
- Posts: 1785
- Joined: 02 Mar 2009, 17:02
Re: Help on Subfolder creation
You will need to use the [ Expert ] tab, [ Use target file parent URL Regular Expression to create sub-folder ] option in the [ Sub-folders ] section of the project properties and add the following Regular Expression:
Expression: theabc\.com/(constantfolder/[^/]+)/
Result: [#1]
Basically, when you want to match a text between / and / (which is usually a folder name in any URL) - use the following RE:
/([^/]+)/
So, when you want to match the first folder after a domain name (any domain name) - you can use this RE:
https://[^/]+/([^/]+)/
When you use [^...] it means: match any character until you meet any character in square brackets after the ^. And the part inside the parentheses is called a match group. You can use up to 9 of them in the Result field. For example, let's take this URL:
https://www.theabc.com/constantfolder/another-folder/
And the following Regular Expression:
https://(www\.theabc\.com)/([^/]+)/([^/]+)/
It will match the above URL and put the following text into the match groups:
[#0]: https://www.theabc.com/constantfolder/another-folder/
[#1]: www.theabc.com
[#2]: constantfolder
[#3]: another-folder
And the Result field allows to add any custom text along with the group matches, so you can combine the group matches any way you want to create a folder name that you need. For example, if you use the following Result with the above RE:
[#2]/[#3]
your folder name will be:
constantfolder/another-folder
But you can also do it like this:
[#3]-is-a-sub-folder-of-[#2] on the domain of [#1]
the folder name will be:
another-folder-is-a-sub-folder-of-constantfolder on the domain of www.theabc.com
Expression: theabc\.com/(constantfolder/[^/]+)/
Result: [#1]
Basically, when you want to match a text between / and / (which is usually a folder name in any URL) - use the following RE:
/([^/]+)/
So, when you want to match the first folder after a domain name (any domain name) - you can use this RE:
https://[^/]+/([^/]+)/
When you use [^...] it means: match any character until you meet any character in square brackets after the ^. And the part inside the parentheses is called a match group. You can use up to 9 of them in the Result field. For example, let's take this URL:
https://www.theabc.com/constantfolder/another-folder/
And the following Regular Expression:
https://(www\.theabc\.com)/([^/]+)/([^/]+)/
It will match the above URL and put the following text into the match groups:
[#0]: https://www.theabc.com/constantfolder/another-folder/
[#1]: www.theabc.com
[#2]: constantfolder
[#3]: another-folder
And the Result field allows to add any custom text along with the group matches, so you can combine the group matches any way you want to create a folder name that you need. For example, if you use the following Result with the above RE:
[#2]/[#3]
your folder name will be:
constantfolder/another-folder
But you can also do it like this:
[#3]-is-a-sub-folder-of-[#2] on the domain of [#1]
the folder name will be:
another-folder-is-a-sub-folder-of-constantfolder on the domain of www.theabc.com