Rename folder by file's first word?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Rename folder by file's first word?

Postby someoneabc » Wed Nov 30, 2011 8:05 pm

Hello everyone,

My problem is somewhat weird but I think there has got to be a way around it.
Suppose I have the following files:

Tokyo - Madrid.doc
Tokyo - New York.doc
London Tokyo New York.doc
2011 London New York.doc
2011 - Anonymous.doc

I would like to create new folders named by the first word of the file only. And then move these files into them. So in this case I will only have 3 folders for the 5 files:

Tokyo> Tokyo - Madrid.doc
Tokyo> Tokyo - New York.doc
London> London Tokyo New York.doc
2011> 2011 London New York.doc
2011> 2011 - Anonymous.doc


I have thousands of these files and I would really appreciate if someone showed me if this can be done in BRU. I googled it and my problem seems unique.

Thanks..
someoneabc
 
Posts: 7
Joined: Sun Apr 29, 2007 3:22 pm

Re: Rename folder by file's first word?

Postby bitmonger » Thu Dec 08, 2011 9:32 am

Bulk Rename is always my goto program for renaming.
However, in this case I don't think it is designed to create directories from parts of the name.
Rather than leave you without a solution I would respectfully suggest another free renaming program called PFrank.
found at:
http://www3.telus.net/pfrank/

It allows a special (?B) extension to the regex which does exactly what you want - (it allows a forward slash to be used in the replace to indicate creation of a subdirectory)

Use (?B)^([^ ]+)(.+) as your search pattern
and \1/\1\2 in your replace pattern

Let's use Tokyo - Madrid.doc as an example

^([^ ]+) captures everything up to the first space into \1 i.e. Tokyo
the (.+) captures the rest of the filename into \2 i.e. - Madrid.doc

The forward slash tells the program you want to use whatever is before it as a new subdirectory, with what follows as the filename within that subdirectory.

so the replace \1/\1\2 would translate to Tokyo\Tokyo - Madrid.doc

Worked fine on my machine.

HTH,
Bit
bitmonger
 
Posts: 24
Joined: Sat Sep 22, 2007 5:05 am


Return to BRU Support