View previous topic :: View next topic |
Author |
Message |
Tyri
Joined: 04 Jul 2011 Posts: 2
|
Posted: Mon Jul 04, 2011 10:19 pm Post subject: Rename with path-regex |
|
|
Hi.
Is it possible, to rename a File with use variables/Regex-Matches from the parent folder?
eg. File:
parent\Folder123\MyFileName.txt
Replace it to:
parent\Folder123\MyFileName_123.txt
I've tried to use this Regex, but it doesn't work.
Search-Pattern:
Code: | Folder(\d+)/\(.*).txt |
Replace-Pattern:
Code: | Folder\1/\\2_\1.txt |
Is this possible?
Or better: Direct move the file to the parent folder.. so i have in the "parent"-folder the files of MyFileName_123.txt?
Hope you can help me.
- Tyri |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Tue Jul 05, 2011 6:38 am Post subject: |
|
|
When you rename using regular expressions, the expression only processes the filename. It knows nothing about the parent folders.
You have to use the pre-defined 'insert parent folder' command in combination with regular expressions to do what you want.
e.g.
Row: 1
Search:
Replace: '*Insert Folder after*Prefix*'
Custom Format String for Insertion:
'%P1Folder%'
Row: 2
Search: Folder'
Replace:
Use row 1 to bring the parent folder name into the filename and then use the remaining rows to massage the combination.
Hope that helps.
Peter. |
|
Back to top |
|
|
Tyri
Joined: 04 Jul 2011 Posts: 2
|
Posted: Thu Jul 07, 2011 9:11 am Post subject: |
|
|
Great!
It works
I like your Program - thank you. |
|
Back to top |
|
|
|