Add folder name to rename files

Have a suggestion for "Everything"? Please post it here.
Post Reply
jeyoh
Posts: 1
Joined: Mon Jan 25, 2021 4:22 pm

Add folder name to rename files

Post by jeyoh »

Didn't find a function to add a folder name to the new file name, for example
Old Filenames:
C:\Folder\File1.ext
C:\Folder\File2.ext
C:\Folder\File3.ext

Old Format:
%1
New Format:
%F%1
New Filenames:
C:\Folder\FolderFile1.ext
C:\Folder\FolderFile2.ext
C:\Folder\FolderFile3.ext
Thx bro
raccoon
Posts: 1015
Joined: Thu Oct 18, 2018 1:24 am

Re: Add folder name to rename files

Post by raccoon »

This already works. I just don't know what %F is supposed to be in your example. But here's how you do it, and I just tested it myself.

Old full paths and filenames:
C:\Folder\File1.ext
C:\Folder\File2.ext
C:\Folder\File3.ext

Old format:
C:\Folder\%1.ext

New format:
C:\Folder\SubFolder\%1.ext

New full paths and filenames:
C:\Folder\SubFolder\File1.ext
C:\Folder\SubFolder\File2.ext
C:\Folder\SubFolder\File3.ext

Everything will create the new SubFolder and move the files into it.

Edit: Oh, I see what you were asking for in your example, and here's how you achieve that output as well.

Old format:
C:\%1\%2.ext

New format:
C:\%1\%1%2.ext

The key here is that you get to define your %1, %2 verbs in the "Old format" so you can utilize them within the "New format." You just neglected to define them properly.
Last edited by raccoon on Mon Jan 25, 2021 9:22 pm, edited 2 times in total.
raccoon
Posts: 1015
Joined: Thu Oct 18, 2018 1:24 am

Re: Add folder name to rename files

Post by raccoon »

If you're working with extra tricky files and folders from multiple locations, here's a practical example people might find useful.

Task: Move all video subtitles into a folder named "Subs".

Old format:
M:\%1\%2.srt

New format:
M:\%1\Subs\%2.srt

Just make sure that none of the selected files for renaming already exist in a \Subs subfolder, or they'll be placed in a \Subs\Subs folder.

Similarly, you can move them out of the Subs subfolder into their parent folder.

Old format:
M:\%1\Subs\%2.srt

New format:
M:\%1\%2.srt
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Add folder name to rename files

Post by NotNull »

You can do that already in the current version of Everything.

You are using the rename routine. That will only affect the name and does not include the path of fiules.
Instead, use Advanced Move to Folder... ( under menu:Edit > Advanced)


Method 1: Use functions
When you click on the little triangles at the right, you will see functions you can use to create this:
(sorry; random files, not very clear)
2021-01-25 22_47_43-.png
2021-01-25 22_47_43-.png (39.71 KiB) Viewed 9223 times
For copy paste:

Code: Select all

%1
$pathpart(%1)\$strippath($pathpart(%1))$strippath(%1)
Method 2: Use regular expressions (regex)
This is a little less straightforward, especially if you are not familiar with regex ...
Click on the triangles to learn more about this syntax.
2021-01-25 22_54_50-Move To.png
2021-01-25 22_54_50-Move To.png (16.87 KiB) Viewed 9223 times
For copy paste:

Code: Select all

^(.*)\\([^\\]*)\\([^\\]*)$
\1\\\2\\\2\3
Post Reply