Move all selected files and folders one level up.

Discussion related to "Everything" 1.5 Alpha.
Post Reply
tassos0104
Posts: 11
Joined: Sat Oct 07, 2023 10:38 pm

Move all selected files and folders one level up.

Post by tassos0104 »

Trying to figure out a way to move all files and folders from a selection after a search, one level up to their parent folder.
Can this be done with the Advanced copy to folder maybe? Not sure how to use regex to refer to the parent path.
I found this post but not quite the same with what I am trying to do:

viewtopic.php?p=52964
void
Developer
Posts: 16739
Joined: Fri Oct 16, 2009 11:31 pm

Re: Move all selected files and folders one level up.

Post by void »

Please try the following:
  • Select multiple files/folders in Everything.
  • From the Edit menu, under the Advanced submenu, click Advanced Move to Folder.
  • Check Regular expressions.
  • Set the old format to:
    ^(.*)\\[^\\]*\\([^\\]*)$
  • Set the New format to:
    $1:\\$2:
  • Examine the newly generated filenames and click OK.
  • Skip moving files that have already moved with folders.
tassos0104
Posts: 11
Joined: Sat Oct 07, 2023 10:38 pm

Re: Move all selected files and folders one level up.

Post by tassos0104 »

Awesome it works!
Thank you, now I'll study the regex and try to understand it.
Your software is amazing! ;)
void
Developer
Posts: 16739
Joined: Fri Oct 16, 2009 11:31 pm

Re: Move all selected files and folders one level up.

Post by void »

^(.*)\\[^\\]*\\([^\\]*)$
^ = match start of filename
( ) = capture group to be recalled in the new format with $1: and $2:
.* = match any character any number of times.
\\ = match a single literal \
[^\\]* = match any character except \ and number of times.
$ = match the end of the filename.


$1:\\$2:
$1: = recall the match inside the first ( ) brackets from the old filename. (the path part -with the last parent name removed)
$2: = recall the match inside the second ( ) brackets from the old filename. (the name part)
tassos0104
Posts: 11
Joined: Sat Oct 07, 2023 10:38 pm

Re: Move all selected files and folders one level up.

Post by tassos0104 »

Thank you, but what I don't quite understand is how '^(.*)\\' captures the whole path part -with the last parent name removed and not from the beginning to the first backslash. It seems that it jumps all the backslashes and goes to the last one and then '[^\\]' seems to look backwards for the next (previous) backslash... I am confused with this part only. The rest I understand.
void
Developer
Posts: 16739
Joined: Fri Oct 16, 2009 11:31 pm

Re: Move all selected files and folders one level up.

Post by void »

(.*) is greedy.

It will capture as much text as possible before it checks for the following pattern.
(in our case: \ + another folder name + \ + followed by the last name part)

[^\\]* captures a single name.

We don't capture the middle folder name.

An example might help:

Code: Select all

Sample path:  C:\Program Files\Everything\Everything.exe
             |\______________/|\________/|\____________/|
             |        |       |     |    |       |      |
             ^       (.*)     \\  [^\\]* \\   ([^\\]*)  $
tassos0104
Posts: 11
Joined: Sat Oct 07, 2023 10:38 pm

Re: Move all selected files and folders one level up.

Post by tassos0104 »

Thank you so much for your regex explanation - it makes sense now.
Post Reply