Author Topic: searching within filenames  (Read 6132 times)

Offline k_bennett

  • Newcomer
  • *
  • Posts: 14
    • View Profile
searching within filenames
« on: June 29, 2007, 01:06:28 PM »
Greetings,

I have a bunch of files that end in the format "filename.jpg 1", and I'd like to get rid of the " 1" (that's a space and a number 1). I can't seem to figure out how to search/select the proper files -- the Find box ignores the space and returns every filename with the number 1 in it. (Not useful.)

Any idea if it's possible to select these images, and, once selected, somehow get rid of the final two characters?

Thanks.
--Ken

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24382
    • View Profile
    • Camera Bits, Inc.
Re: searching within filenames
« Reply #1 on: June 29, 2007, 02:05:00 PM »
Ken,

I have a bunch of files that end in the format "filename.jpg 1", and I'd like to get rid of the " 1" (that's a space and a number 1). I can't seem to figure out how to search/select the proper files -- the Find box ignores the space and returns every filename with the number 1 in it. (Not useful.)

Any idea if it's possible to select these images, and, once selected, somehow get rid of the final two characters?

Our Find/Replace doesn't work with filenames so you won't be able to do that directly.  But what you could do is select all of the files that just have a single digit following the extension (0-9) and then use the Rename dialog with the following rename string:

{filename:0,-6}

Then if you have some with two digits (10-99) select them and use this as the rename string:

{filename:0,-7}

If you have more than two digits (100-999) then change the negative number to -8 and so on.


I just tested some images that ended in '.jpg 1' and '.jpg 2' and my first renaming example worked just fine.

-Kirk
« Last Edit: July 01, 2007, 06:51:20 PM by Kirk Baker »

Offline k_bennett

  • Newcomer
  • *
  • Posts: 14
    • View Profile
Re: searching within filenames
« Reply #2 on: June 30, 2007, 01:33:07 PM »
Thanks, Kirk, I'll give it a shot when I get to work. This solution will be a big help.

--Ken

Offline k_bennett

  • Newcomer
  • *
  • Posts: 14
    • View Profile
Re: searching within filenames
« Reply #3 on: July 01, 2007, 06:17:16 PM »

Our Find/Replace doesn't work with filenames so you won't be able to do that directly.  But what you could do is select all of the files that just have a single digit following the extension (0-9) and then use the Rename dialog with the following rename string:

{filenamebase:0,-6}

I just tested some images that ended in '.jpg 1' and '.jpg 2' and my first renaming example worked just fine.

-Kirk


Kirk,

I just tested this with some sample files, and while it did eliminate the ' 1' (space-1) after the jpg extension, it also wiped out the last six characters of the filename before the suffix. Then I studied your code for a minute, and tried

{filenamebase:0}

and it worked. I checked it on several files, with single- and double-digit numbers after the jpg suffix.

Thanks,

Ken

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24382
    • View Profile
    • Camera Bits, Inc.
Re: searching within filenames
« Reply #4 on: July 01, 2007, 06:52:47 PM »
Ken,


Our Find/Replace doesn't work with filenames so you won't be able to do that directly.  But what you could do is select all of the files that just have a single digit following the extension (0-9) and then use the Rename dialog with the following rename string:

{filenamebase:0,-6}

I just tested some images that ended in '.jpg 1' and '.jpg 2' and my first renaming example worked just fine.

-Kirk


Kirk,

I just tested this with some sample files, and while it did eliminate the ' 1' (space-1) after the jpg extension, it also wiped out the last six characters of the filename before the suffix. Then I studied your code for a minute, and tried

{filenamebase:0}

and it worked. I checked it on several files, with single- and double-digit numbers after the jpg suffix.

I see I meant to say to use {filename} instead of {filenamebase}.  I edited my earlier post.

Either way, you found a solution.

-Kirk

Offline k_bennett

  • Newcomer
  • *
  • Posts: 14
    • View Profile
Re: searching within filenames
« Reply #5 on: July 02, 2007, 07:02:08 AM »
Kirk,

1119 files later, and it worked just fine. Thanks again.

--Ken