Author Topic: need help with renaming files  (Read 3855 times)

Offline Pompo

  • Member
  • **
  • Posts: 66
    • View Profile
    • Alfonso Bresciani
need help with renaming files
« on: September 26, 2017, 11:23:53 AM »
I'm shooting for a tv show and they want me to rename (so they can keep separate) behind the scene shots from main acting shots.

SO I need to know if it's possible at all after I re-named all files like:

TvShowName-Season-101_SCN1_MyNAme0001
TvShowName-Season-101_SCN1_MyNAme0002
TvShowName-Season-101_SCN1_MyNAme0003 

etc. to go back to these files, select the behind the scenes shots and rename only those selected from "SCN1" to "BTS" WITHOUT altering anything else in the file names, keeping the number sequential too, everything else, unchanged, but SCN1 changed to BTS?

Offline FVlcek

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: need help with renaming files
« Reply #1 on: September 26, 2017, 11:59:54 AM »
Hi,

I think you have two options - using PM fully, or use PM to save a simple text file containing the names of the selected files and make a simple script around the list, renaming them in terminal.

It should be possible, with Rename using variable substring extraction, althoughit seems would have to do a two pass on renaming the files.

Strangely, I thought a simple one-pass rename using TvShowName-Season-101_BTS{filenamebase:25,99} would work (at least as long as all files have 101 and not 102 etc in them), but it does not. Probably has to do with the order the variables are resolved.

Experiment with this:

first rename string:
{filenamebase:25,99}
(this will cut the first 25 characters from the original name, leaving just 1_MyNAme0001, the 99 at the end just tells it leave 99 characters untouched, 99 is just for safety as it should be long enough)

obviously the first part of the filename would have to be constant length, and there should not be any files like 101_SCN1_MyName001 and 102_SCN1_MyName001 as these would produce an error since both would truncate to 1_MyName001...

second rename string:
TvShowName-Season-101_BTS{filenamebase}
(that would simply add the string we cut in the first step, but with BTS instead of SCN to the beginning of now truncated filename

If your filenames are consistent in length (substring extraction needs constant length to work!), that should work nicely.

Try doing that with a backup set of the files, if it works for you.

If your filenames are not constant in length, or somehow more convoluted (like having multiple sets of 101, 102 etc with same MyName00x), your best bet would be to Export the selected filenames using PM (Export, Text Exporter, and just put whatever variables like {filenamebase} there), generating a simple text file containing all the filenames on each line. You could even add your OS commands right in the export window, but you would probably have to edit it with some text editor afterwards. Something like TextWrangler (OSX) that allows find and replace with GREP support would be best. Or just make a script to do it using PERL or something like that. In the Export, something as simple as mv {filename} {filename} (on OSX) and later editing the text file replacing every second SCN with BTS, finally saving it as a script to run would probably work.

Obviously, you should make the renaming on a separate copy of the files in case something goes wrong.

See full documentation on renaming here:
http://wiki.camerabits.com/en/index.php/User_Manual_Flat_View#Variable_Substring_Extraction
« Last Edit: September 26, 2017, 12:05:23 PM by Frantisek Vlcek »

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: need help with renaming files
« Reply #2 on: September 26, 2017, 12:37:52 PM »
Or you could simply use the Find and Replace panel, selecting those images that need their SCN1 changed to BTS, entering SCN1 as the find string and BTS as the Replace string, and choosing to search filenames.

http://wiki.camerabits.com/en/index.php/User_Manual_Flat_View#Find_and_Replace

HTH,

-Kirk

Offline FVlcek

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: need help with renaming files
« Reply #3 on: September 27, 2017, 02:50:41 AM »
For some reason, Find and Replace dialog doesn't offer Filenames checkbox in my version of PM, unlike it is shown in the Wiki manual. The option to search filenames is only there in the Find dialog... (PM ver. 18895, OS X 10.12.6). Thus the convoluted solution using two pass rename and variables with substring extraction. See attached screenshot.

Offline Tony Hall

  • Member
  • **
  • Posts: 78
    • View Profile
    • Tony Hall Photography
Re: need help with renaming files
« Reply #4 on: September 27, 2017, 03:23:17 AM »
You need to deselect Use Classic IPTC dialogs in the Accessibility section of Preferences.

Then when you select Find and Replace... (shift-cmd-F) you should get the correct dialog.
« Last Edit: September 27, 2017, 03:26:51 AM by Tony Hall »

Offline Pompo

  • Member
  • **
  • Posts: 66
    • View Profile
    • Alfonso Bresciani
Re: need help with renaming files
« Reply #5 on: September 27, 2017, 09:43:58 AM »
Find and replace works great. Thank you very much everyone!

Offline FVlcek

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: need help with renaming files
« Reply #6 on: September 28, 2017, 02:37:40 AM »
You need to deselect Use Classic IPTC dialogs in the Accessibility section of Preferences.

Then when you select Find and Replace... (shift-cmd-F) you should get the correct dialog.

D'OH! Thanks! Didn't think of that :)