How to SELECT filenames with spaces

A swapping-ground for Regular Expression syntax

How to SELECT filenames with spaces

Postby virgule » Wed Apr 05, 2017 2:09 pm

This is one is a bummer. Please note that the question below refers to SELECT, not REPLACE (which is easy and discussed a thousand times in the forum)

The help file explains that the selection box accepts wildcards and multiple values...separated by spaces! This means it's impossible to pre-select a list of files if they contain spaces and you are trying precisely to narrow down those with and without spaces. The help file doesn't say how to work around spaces in filenames, and the forum search box doesn't accept "select" or "space" because they are too common words :-(

Here is what I am trying to do:
- I have a few thousand mp3 which start by e.g. 00-songname.mp3 or 00 - songname.mp3 or 00- songname.mp3 or 00 -songname.mp3
- I want to remove all the prefixes 00- and "00 - " and "00 -" and "00- " in order to end up with "songname.mp3" only

Removing a few characters in front is easy with BRU (filter #5). Using a selection filter of eg "* - *.mp3" selects (all the files + any file with a dash + any mp3 file)...which is useless for my purpose :-)

The files in left pane are listed in alphabetical order, and I see a small range of "xx-songname" followed by a small range of "xx -songname" and "xx- songname" and finally "xx - songname". It would be easy to select manually if I had a dozen files, but here I have to manually select every single of a few thousand files :-(

There has to be a better way. Thousands thanks to the kind smart guy/gal who can help me!

PS: I think this case should be documented in the help file, as spaces in filenames is a common thing and it's the only exception I can see in the selection filter.
virgule
 
Posts: 3
Joined: Wed Apr 05, 2017 1:53 pm

Re: How to SELECT filenames with spaces

Postby KenP » Wed Apr 05, 2017 3:07 pm

I'm guessing that you're under the impression that you need to filter the files in order to select only the files with spaces before the song name so you can rename them, but that's not really necessary.

If you want to rename the files that start with digits, followed by a hyphen or spaces and a hyphen in any order, try this:

In the folder tree pane select the folder that the files are in, in the main window select all the files.

RegEx (1)
Match: ^(?:\d*)(?:\s-\s|\s-|-\s|-)(.*)
Replace: \1

Only the files that start with digits followed by spaces or a hyphen will turn green in "New Name" column.

--------------------------------------

If you just want to filter all the files that start with digits, followed by a hyphen or spaces and a hyphen in any order, try this:

Filter (12)
Mask: ^(\d*)(\s-\s|\s-|-\s|-)
RegEx: Selected

If neither of these are what you're trying to do let us know :wink:
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: How to SELECT filenames with spaces

Postby virgule » Wed Apr 05, 2017 7:36 pm

Ken,

Thanks for the idea. Not exactly what I was looking for, but I might be able to work around my issue with this. It seems to cover a big chunk of my problem. I'll post an update if I am stuck.

PS: I was hoping to make 4 x selections, then apply 4 x filter #5 to remove the needed number of characters from the prefix. If all the selected files have the same prefix pattern, then I can safely apply the same # of characters to remove - easy.
Are you suggesting that there is no simple way to make my selection filter? No way to "escape" the " " character, or change a config setting to change the delimiter in filter #12? RegEx is really powerful, but it's not easy for everyone...

Thank you
virgule
 
Posts: 3
Joined: Wed Apr 05, 2017 1:53 pm

Re: How to SELECT filenames with spaces

Postby KenP » Wed Apr 05, 2017 8:28 pm

I'm sorry but I don't understand what you're trying to do, in your opening post you said you wanted to rename "00-songname.mp3 or 00 - songname.mp3 or 00- songname.mp3 or 00 -songname.mp3" to songname.mp3.

The Regex I posted before does precisely that, it gets rid of the digits hyphens and spaces before the song title, I also posted the code to filter the files that start with digits and have spaces and/or a hyphen.

Are you saying that the prefixes you refer to are not always digits but sometimes words ?

Perhaps if you post a few real world examples of exactly what you have and what you want to do with them it would help.
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: How to SELECT filenames with spaces

Postby virgule » Thu Apr 06, 2017 4:51 am

Ken,

I have fixed my problem 100% thanks to your RegEx code. Thank you.

As it is often the case, RegEx can do more things than what the amateur can see at first look :-)

In case someone else comes across this thread: I was embarking on a clumsy solution of 1) selecting files with identical patterns, 2) removing a fixed number of prefix characters since patterns were known to be identical. You suggested a smart solution...

What I failed to see is that there were a lot more patterns than I imagined in my long list of files, and the Regex approach covered much more ground, much faster, than the clumsy 2-step approach above. After a 1st pass, I was able to sort the new filenames alphabetically, and see a much simpler and shorter list that was trimmed with just a few tweaks.

Thanks for the kind help, much appreciated
virgule
 
Posts: 3
Joined: Wed Apr 05, 2017 1:53 pm

How to FILTER filenames with spaces

Postby dan_pub » Mon Jul 03, 2017 11:15 pm

I have a directory full of pictures and txt files which causes BRU to crash. Most filenames begin with a country name, then a space, then a description of the scene.
For example "Bahrain S-70A Blackhawk.jpg" or "Saudi AS-332F Super Puma RSNF.jpg"

If I start BRU without a filter on this directory, it always crashes. If I switch to this directory with a filter, for ex "Bahrain*", sometimes it crashes and sometimes not, depending on the country filtered. So it is certain specific files that cause the crash. I'm trying to isolate which ones. I have found that at least one file "Egypt *" is a culprit. Since I have over one thousand "Egypt *" files, I want to filter on the next letter to narrow it down. First filter on "Egypt A*", then on "Egypt B*", etc.

Even using the advice given by Ken, for the life of me I cannot get it right. Just spent a few hours on it and failed. Could you please help me out and post the proper way to do this?
Thank you.

PS: I'm using BRU 3.0.0.1 on Win7 Pro SP1. The problem directory has 6'873 files tonight, but others have more without crash.
dan_pub
 
Posts: 4
Joined: Mon Feb 06, 2012 9:31 am

Re: How to SELECT filenames with spaces

Postby Admin » Tue Jul 04, 2017 2:17 am

Hi, does it always crashes using "Egypt" ? Are you including subfolders? thanks
Admin
Site Admin
 
Posts: 1464
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to SELECT filenames with spaces

Postby dan_pub » Tue Jul 04, 2017 12:00 pm

Hi,
I am not including any subfolder.

>does it always crashes using "Egypt" ?
I am not sure how you mean it. Filtering on "Egypt" does not crash in several other folders. In this particular one, it always does.
I have sent a DIR listing of this folder to the support@bulk address. I hope it helps.
dan_pub
 
Posts: 4
Joined: Mon Feb 06, 2012 9:31 am

Re: How to SELECT filenames with spaces

Postby Admin » Wed Jul 05, 2017 1:34 am

Hi, yes, I meant if filtering this specific directory using "Egypt" always crashes BRU. Do you just enter ""Egypt" in the File Filter mask? thanks
Admin
Site Admin
 
Posts: 1464
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to SELECT filenames with spaces

Postby dan_pub » Wed Jul 05, 2017 11:53 am

>Do you just enter ""Egypt" in the File Filter mask?

Yes. When I enter "Egypt*" as mask, it always crashes on this directory. If I enter it in other directories, it doesn't.
If I enter something else, say "*AB-212*" or "Saudi*", it doesn't.

What is the syntax to filter files beginning with "Egypt A" ?
dan_pub
 
Posts: 4
Joined: Mon Feb 06, 2012 9:31 am


Return to Regular Expressions