Inserting a portion of the parent folder name in filenames
Hello,
I am have picture files in folders and I am trying to insert a portion of the parent folder name in the file names at a given position. I have been struggling with it and would greatly appreciate some ideas.
For example:
Folder name: Family - 2019-02-26 - Crean Volleyball El Dorado
Original file names:
Family - 2019-02-26 - 019.jpg
Family - 2019-02-26 - 019 - Posting.jpg
Desired file name:
Family - 2019-02-26 - Crean Volleyball El Dorado - 019.jpg
Family - 2019-02-26 - Crean Volleyball El Dorado - 019 - Posting.jpg
The position of the insertion text to insert and the position of the insertion point do not change, but the length of the inserted text will vary.
In theory I can replace the entire filename and just leave behind the sequence ( - 019, etc.). I have also figured out how to just replace the entire filename with the entire folder name and add a sequence of numbers, but I need to keep the existing numbering not start at 001. The reason for this is I need to be able to match the files back to the original source file and changing the sequence will negate that.
In the example above the original file would have been named 2019-02-26 - Crean Volleyball El Dorado - 019.NEF
I also figured out how to replace the name keeping the sequence number by using RSubstr 3, but since some of the files have additional text beyond the sequence this would not work.
I am sure there is a way to get this done, but I am racking my brain unsuccessful, I would appreciate any tips.
Mike.
I am have picture files in folders and I am trying to insert a portion of the parent folder name in the file names at a given position. I have been struggling with it and would greatly appreciate some ideas.
For example:
Folder name: Family - 2019-02-26 - Crean Volleyball El Dorado
Original file names:
Family - 2019-02-26 - 019.jpg
Family - 2019-02-26 - 019 - Posting.jpg
Desired file name:
Family - 2019-02-26 - Crean Volleyball El Dorado - 019.jpg
Family - 2019-02-26 - Crean Volleyball El Dorado - 019 - Posting.jpg
The position of the insertion text to insert and the position of the insertion point do not change, but the length of the inserted text will vary.
In theory I can replace the entire filename and just leave behind the sequence ( - 019, etc.). I have also figured out how to just replace the entire filename with the entire folder name and add a sequence of numbers, but I need to keep the existing numbering not start at 001. The reason for this is I need to be able to match the files back to the original source file and changing the sequence will negate that.
In the example above the original file would have been named 2019-02-26 - Crean Volleyball El Dorado - 019.NEF
I also figured out how to replace the name keeping the sequence number by using RSubstr 3, but since some of the files have additional text beyond the sequence this would not work.
I am sure there is a way to get this done, but I am racking my brain unsuccessful, I would appreciate any tips.
Mike.
Reply to #1:
Hi Miguel,
Try a replace method:
Replace: ".* - .* - (\d+)"
With: "<foldername> - $1"
[NOTE: Only what is inside the quotation marks]
Occurrence: All
Case sensitivity: doesn't matter
Use regular expressions: CHECKED
Apply to: Name (only)
This works on your example and should work as long as the [space][dash][space] patterns remain consistent. If you have problems with some files you'll need to post more examples.
Best,
DF
Hi Miguel,
Try a replace method:
Replace: ".* - .* - (\d+)"
With: "<foldername> - $1"
[NOTE: Only what is inside the quotation marks]
Occurrence: All
Case sensitivity: doesn't matter
Use regular expressions: CHECKED
Apply to: Name (only)
This works on your example and should work as long as the [space][dash][space] patterns remain consistent. If you have problems with some files you'll need to post more examples.
Best,
DF