Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PowerRename] variable pattern notation for parent folder #8484

Open
akulmehta opened this issue Dec 8, 2020 · 12 comments
Open

[PowerRename] variable pattern notation for parent folder #8484

akulmehta opened this issue Dec 8, 2020 · 12 comments
Labels
Idea-Enhancement New feature or request on an existing product Product-PowerRename Refers to the PowerRename PowerToy

Comments

@akulmehta
Copy link

akulmehta commented Dec 8, 2020

📝 Description

Similar to File Creation Date Replace Notation, have a variable pattern notation $PF (Parent Folder) which can be used in the Replace with: field to add the parent folder name to the output renamed files.

Example

Current directory

└─ 0
   └─ file1.png
└─ 1
   └─ file1.png
└─ 2
   └─ file1.png
   └─ file2.png

Perform a regex search like : (.*).png, which captures the filename into variable $1

Replace with: $PF_$1.png

Expected output:

└─ 0
   └─ 0_file1.png
└─ 1
   └─ 1_file1.png
└─ 2
   └─ 2_file1.png
   └─ 2_file2.png

If you'd like to see this feature implemented, add a 👍 reaction to this post.

@ghost ghost added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Dec 8, 2020
@enricogior
Copy link
Contributor

@akulmehta
what is the scenario for which this feature is a requirement, instead of just going to the parent folder and start PowerRename from there?

@enricogior enricogior added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-PowerRename Refers to the PowerRename PowerToy and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Dec 8, 2020
@akulmehta
Copy link
Author

A possible scenario is that maybe the filenames are similar (e.g. above you can see all folders have file1.png as camera's might be producing these serially in folders) but the folder names are what differentiates the files (above I have just put 0, 1, 2 but they could be specific names which might be for example trip names etc). But rather than having them in a nested folder structure if you want to flatten the directory structure, then you cannot do that as the files would be the same filename. Using PowerRename one could append/prepend the folder name to the file name thereby differentiating the files below.

The point is that if the folder name carries some information which you would like to have in the filename. Currently there is no way to do it except maybe using PowerShell.

@enricogior I am not sure if this answers your question so please let me know if I missed something.

@ghost ghost added Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Dec 8, 2020
@enricogior enricogior added Idea-Enhancement New feature or request on an existing product and removed Needs-Team-Response An issue author responded so the team needs to follow up Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Dec 13, 2020
@dhyannirav
Copy link

I'd like to do exactly this to put all tracks of music albums in one directory. The tracks are named 01_xxx 02_xxx ... in each folder, so I'd like to prefix them with the parent folder name.

@enricogior enricogior changed the title PowerRename variable pattern notation for parent folder [PowerRename] variable pattern notation for parent folder Feb 9, 2021
@typpos
Copy link

typpos commented Jan 3, 2022

Yes please.

Use case:
Parent folders "Theme 1", "Theme 2", "Theme 3"... "Theme 95".
Each folder contains 130 icons named "01.ico" "02.ico" ...

Objective: Move all ico files into the same folder, but adjust file names to be meaningfully unique , ie, prefix file names with parent folder name, so I can later move all files to the same folder.

@AverageHoarder
Copy link

AverageHoarder commented Nov 11, 2022

I would also love this as a feature. Especially for music. I usually have a .log and a .cue file in album folders and I want them to be named in a specific way.

Example:
Music/Braxton, Anthony/Ninetet (Yoshi's) 1997, Vol. 1 [CD 1]/
-something.log
-something.cue
Music/Braxton, Anthony/Ninetet (Yoshi's) 1997, Vol. 1 [CD 2]/
-something.log
-something.cue

I want them use this syntax:
$ParentDir.cue for .cue files
and
$GrandparentDir - $ParentDir.log for .log files
to end up with

Music/Braxton, Anthony/Ninetet (Yoshi's) 1997, Vol. 1 [CD 1]/
-Braxton, Anthony - Ninetet (Yoshi's) 1997, Vol. 1 [CD 1].log
-Ninetet (Yoshi's) 1997, Vol. 1 [CD 1].cue
Music/Braxton, Anthony/Ninetet (Yoshi's) 1997, Vol. 1 [CD 2]/
-Braxton, Anthony - Ninetet (Yoshi's) 1997, Vol. 1 [CD 2].log
-Ninetet (Yoshi's) 1997, Vol. 1 [CD 2].cue

I can achieve this in AdvancedRenamer by using "DirName:1" for .cue files and "DirName:2 - DirName:1" for .log files.
But I'd much prefer to be able to do this with PowerRename.

@xanderificnl
Copy link

xanderificnl commented May 10, 2023

Another example:

subs/a/1_english.srt  -> subs/a.srt
subs/b/5_english.srt  -> subs/b.srt
subs/c/3_english.srt  -> subs/c.srt

Allowing us to capture and match on the entire path that's been opened (i.e. subs/) would be wonderful, i.e.:

subs\\(.*)\\.*English\.srt -> $1.srt

FWIW, with mmv on Linux, this would work:

mmv '*/*_English.srt' '#1.srt'

@EStegenburgs
Copy link

Also, useful on measurement generated files that, as others have pointed out, in general, might be saved with non-unique filenames but folder names or their overall path define the properties or attributes, which for various reasons you might want or need to include in the filenames, and then one can (optionally) move all files to a single directory.

@cow1337killer3
Copy link

cow1337killer3 commented Oct 7, 2023

Can we please get this? Was surprised it wasn't already a feature.

How about this: $p3 expands to the 3rd directory above the item, etc.

Current item: 'C:\Users\Bob\Downloads\Cool Band\New album\Track 1.mp3'
$p expands to 'Track 1.mp3' (with extension)
$p0 expands to '.mp3' (only extension)
$p1 expands to 'Track 1' (without extension)
$p2 expands to 'New album'
$p3 expands to 'Cool Band'

And it completely avoids the problem of them attempting to include path separators in the new name.

So, renaming from
'.*'
to
'$p3 - $p1 ($p2).$p0'
would give
'Cool Band - Track 1 (New album).mp3'

@06000208
Copy link

06000208 commented Oct 29, 2023

what is the scenario for which this feature is a requirement, instead of just going to the parent folder and start PowerRename from there?

You could have many parent folders on the same level, with information you'd rather be in their files' names.

Without it, the alternative is manually repeating the same process, with that information put into PowerRename per folder, on N amount of folders. Could be two, could be five, could be fifty. Wasted time, you know?

For anyone with a similar need for this feature before it's implemented, Advanced Renamer has it.

@azcom
Copy link

azcom commented Mar 15, 2024

Over 3 years and still not implemented?

This seems like such a basic string to include too so I'm shocked that it's still not been added.

It would be infinitely useful and from the numerous duplicate requests that have been closed in favour of this one it shows that many other people have a need for this too.

@moradizx
Copy link

moradizx commented Jun 10, 2024

An example:

What we have:
Can't append folder name:
image

What is required:
Can append each folder name to all the files in its subfolders
image

@cochetti
Copy link

** USE CASE: IP Security / Doorbell Cameras **

I am processing doorbell camera footage which uses a folder structure based on the date as follows, and segments are stored in 30 second chunks which can then be appended together on the fly and transmitted. As it's a building interior the camera is activated multiple times a day by neighbors and my family. In the photo below, you are seeing only activations on Feb 6th, 2023 between 8 am and 5 pm, the folder structures are massive and filled with tiny files that if contiguous need to be concatenated together to reform the whole video.

  • CAMERASERIAL#
    • YYYY
      • 01
      • 02
      • MM
        • DD
        • DD
        • DD
          • 08
            • 08MM12.data
            • 08MM42.data
          • 09
            • 09MM27.data
            • 09MM57.data
      • 05
        • 01
        • ...
        • ...
        • ...
        • 31
          • 01
          • ...
          • ...
          • ...
          • 23

In this scenario (especially for folks with multiple cameras, this is just a single apartment doorbell camera), it would be great to use PowerRename to bulk add the YYYY-MM-DD portion to each of these files. so that I can put them collectively into a single folder for further processing.

As you note as well, this style of structure is very common in sensor data and in my professional life I have dealt with similar outputs on devices such as blood pressure cuffs, laboratory test results, logs of various forms. Folks often end up resorting to learning basic command-line or using a tool like R or Python for these types of tasks, but some folks also accidentally delete, overwrite, etc their data in the attempt. It would be nice to have a more intuitive and preview-provided method to these types of bulk updates.

Thanks!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea-Enhancement New feature or request on an existing product Product-PowerRename Refers to the PowerRename PowerToy
Projects
Status: No status
Development

No branches or pull requests