move files across different folders and rename them

A swapping-ground for Regular Expression syntax

move files across different folders and rename them

Postby Wilson1 » Wed Mar 26, 2014 5:53 pm

Hi Everyone,

I'm trying to accomplish the following and was wondering if Bulk Rename Utility can handle it.

So I have a folder with 1000s of PST files that looks like this: D:\PST_Files\
john@mydomain.com.pst
john@mydomain.com-1.pst
john@mydomain.com-2.pst
john@mydomain.com-3.pst
...
john@mydomain.com-24.pst
Amy@mydomaine.com.pst
Amy@mydomaine.com-1.pst
Amy@mydomaine.com-2.pst
Amy@mydomaine.com-3.pst
tod@mydomain.com.pst
tod@mydomain.com-1.pst
tod@mydomain.com-2.pst
etc


I need to rename the same "owners" pst files the same (remove the -n before the .pst) and move these into different folders. (create the folders if needed)

So the output should look like this:
Folder1
john@mydomain.com.pst
Amy@mydomaine.com.pst
tod@mydomain.com.pst

folder2
john@mydomain.com.pst
Amy@mydomaine.com.pst
tod@mydomain.com.pst

folder3
john@mydomain.com.pst
Amy@mydomaine.com.pst
tod@mydomain.com.pst

folder4
john@mydomain.com.pst
Amy@mydomaine.com.pst

folder5
john@mydomain.com.pst


Many thanks for your help.
Wilson1
 
Posts: 2
Joined: Wed Mar 26, 2014 5:30 pm

BRU wont create new folders

Postby truth » Thu Mar 27, 2014 8:25 am

BRU never creates new folders, it only renames them.
The closest you'll get is creating the commands that you need.

As a regex-challenge, if you desire:
Frank@domain.com.pst ------> Folder\Frank@domain.com.pst
Frank@domain.com-4.pst ---> Folder4\Frank@domain.com.pst
Joe@domain.com-12.pst ----> Folder12\Joe@domain.com.pst

You could use:
(.+@domain.com)(-*([0-9]*))$
MD Folder\3 & MOVE "\1\2.pst" "Folder\3\\1"

To create below-type commands (in NewNameColumn):
MD Folder4 & MOVE "Frank@domain.com-4.pst" "Folder4\Frank@domain.com".pst
MD Folder & MOVE "Frank@domain.com.pst" "Folder\Frank@domain.com".pst
MD Folder12 & MOVE "Joe@domain.com-12.pst" "Folder12\Joe@domain.com".pst

But you'd still need to: RightClick/ClipboardCopy/NewName+ext to then paste your commands into a batch.
I'd sort the NewName column before right-clicking, if many names shouldnt be matched (or werent filtered).
The regex is actually much simpler if you only need to match names ending as -#.pst
Just post back if you need any help going this route
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: move files across different folders and rename them

Postby Wilson1 » Thu Mar 27, 2014 8:32 pm

Thanks Truth.. I will try some of your suggestions and see if that will get me by.

I'm going to be working with a folder with over 30,000 pst files so any little bit that can reduce the work effort is useful.
Wilson1
 
Posts: 2
Joined: Wed Mar 26, 2014 5:30 pm

BRU wont create new folders

Postby truth » Fri Mar 28, 2014 12:24 am

No worries, I was mainly addressing the regex-challenge, but I foresee no problems if:
You desire the DirStructures above, where all names beginning as Text@domain.com should get moved.
(whether or not those names then end as domain.com.pst or domain.com-#.pst)

If you're concerned about processing so many files, you can always throw-in some 12Filters like:
a* b* c* d* e* to only display filenames beginning with a,b,c,d or e (both upper/lowercase).
That lets you create smaller batches, run them, & be done with those files.

If you have names not in the format: name@domain.com, I'd add another 12Filter=*@*
That filters NamesWithout@ away from BRU's right-pane (regex wont match them anyway).

The main problem is that any selected-file will always have a 'NewName' value.
(even non-matched names will have OrigName assigned to its 'NewName')
So sorting by NewName ensures batchlines (beginning as MD) are grouped together

Once sorted, I would just Crtl-A & paste NewName+ext into a .txt-file, & then edit the .txt
to remove any potential OrigName.pst batch-lines (in case non-matched-names were selected).

Please note I omitted FullDirPaths, focusing more on the regex-match, but its just as easy to:
D:\Joe@domain.com-3.pst ---> C:\NewDirPath\Folder3\Joe\Joe@domain.com
D\:May@domain.com-8.pst ---> C:\NewDirPath\Folder8\May\May@domain.com

Again, just post back if you need any help.
I'd recommend the 'smaller-batch' method, until getting used to it.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions