Rename files only when matching regex

A swapping-ground for Regular Expression syntax

Rename files only when matching regex

Postby Kali » Sat Jul 25, 2015 1:45 am

I want to move some specific files that match a reg ex an only those

I couldn't figure it out and used a work around
1) rename all files matching the reg-ex to 00x, then using Numbering(10) to add a number to all files
2) The moved all files starting in 00x manually (windows explorer sort is fast for 10000+ files)
3) remove the added numbers with Remove(5) from remaining files

This works, but the massive downside is that I use the original filenames.


How do I work with (2)-(11) only on files that match RegEx(1) ?
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby Kali » Thu Jul 30, 2015 1:21 am

I set a $5 bounty on this :D
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby Kali » Mon Aug 03, 2015 1:17 am

Too complex, too easy, or no one here?
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby Admin » Mon Aug 03, 2015 2:06 am

Hi , is this file move or file copy?
How are you doing this step:
Code: Select all
rename all files matching the reg-ex to 00x


thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Rename files only when matching regex

Postby Stefan » Mon Aug 03, 2015 8:17 am

Any renamer will work on matching regex only, and will skip non-matching files.
It is up to the user to develop a working regex, and/or maybe separate his
file into "working groups" and perform more than one renaming action.
So this is a feature per se. Isn't it?



 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Rename files only when matching regex

Postby Admin » Tue Aug 04, 2015 3:06 am

Sorry , I am not sure I understood the requirements.... :(
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Rename files only when matching regex

Postby Kali » Sat Aug 08, 2015 3:27 am

What I need to do
I have a directory with a couple thousand files
I need to take some of those files and move them to a different directory
The files which I need to move match a certain regex which I managed to build.

What I have done
My work-around so far has been to rename the files that match the regex (that is what the tool allows me to do) to something lexicographically low (like 00x). Then inside windows explorer I sort by name, and just move the top files.


So yes, I have a working reg ex. But I would like to move those files, not just rename them.
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby Kali » Sat Aug 08, 2015 3:32 am

The problem with the workaround is that I lose the original file names, which is a problem for the end user
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby Admin » Mon Aug 10, 2015 3:47 am

Hi, you could use a file copy program like ViceVersa PRO to move files based on regex, see:
http://www.tgrmn.com
thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Rename files only when matching regex

Postby Kali » Tue Aug 11, 2015 2:45 pm

Thanks.

That costs some money though. BRU can interprety reg-ex and move files, why not both :D
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby Kali » Wed Sep 02, 2015 3:57 am

Solution Found

Using windows power shell this can be done
It's cumbersome to understand the syntax, but once I got it, it works like charm

http://superuser.com/questions/149537/windows-file-copy-move-with-filename-regular-expressions
Kali
 
Posts: 7
Joined: Sat Jul 25, 2015 1:41 am

Re: Rename files only when matching regex

Postby freddef » Sun Sep 13, 2015 9:47 am

Have the similar problem with regex and I have been using sh, awk and sed for 34 years, but is not perl users. Perl regex is fixing something never broken.

Saw an older answer with a similar problem, but when seeing the solution (http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=2529#p6649) I get a bit frustrated.

I have the regex "__???m" and want to remove it with a simple blank in the "Replace", like in "s/__???m//g"

Why have to \1\3 or what ever to solv my problem? It is to overdo it. If Perl is behind the tool, why not do that interpretation in the code of Bulk Renamer? Simplify for the non-Perl users?

Cheers
Fredde
freddef
 
Posts: 1
Joined: Sun Sep 13, 2015 9:29 am


Return to Regular Expressions