Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

String substitution and regular expressions

From: Photoshop CS5 One-on-One: Fundamentals

Video: String substitution and regular expressions

All right kids, now I'm going to show you a new feature inside the Batch Rename dialog box. It's called String Substitution, and what it means is that you can replace one group of characters with another group of characters, so it's kind of a search and replace by filename, very, very useful. It's a little bit techie though. And we are even going to get into this thing called Regular Expressions, which is absolutely for geeks, I have to tell you that upfront. But if you have a mind for it, it can be extremely useful. So here's what we're going to do, I'm still working inside the 03_open_org folder, I'm going to go ahead and press Ctrl+A or Command+A on the Mac to select all the images, and notice these images of Sammy in a goalie mask, all of them start with A000033 and then a number, all right so we could just go ahead and search and replace that string of characters right there without hurting anything else.

String substitution and regular expressions

All right kids, now I'm going to show you a new feature inside the Batch Rename dialog box. It's called String Substitution, and what it means is that you can replace one group of characters with another group of characters, so it's kind of a search and replace by filename, very, very useful. It's a little bit techie though. And we are even going to get into this thing called Regular Expressions, which is absolutely for geeks, I have to tell you that upfront. But if you have a mind for it, it can be extremely useful. So here's what we're going to do, I'm still working inside the 03_open_org folder, I'm going to go ahead and press Ctrl+A or Command+A on the Mac to select all the images, and notice these images of Sammy in a goalie mask, all of them start with A000033 and then a number, all right so we could just go ahead and search and replace that string of characters right there without hurting anything else.

So I'm going to go up here to the tools menu and I'm going to choose Batch Rename, Ctrl+Shift+R, Command+Shift+R on the Mac and I'm going to switch over from Extension fixer here to String Substitution. And the simplest application of String Substitution is that you're finding one string and you're replacing it with another. So as I recall, it was A 1, 2, 3, 4 zeros followed by two 3s, and I'm going to replace that with Sam as goalie-, let's say, and a hyphen afterwards.

And now, let's check out what I've done. I'll click on Preview and I'll see that only those five images. That's it, even though I have 79 images selected, only those five images are going to be replaced with Sam as goale 1, 2, 3, 4, 5. So that's perfect. I don't have to throw a sequence number on after that because they were already automatically sequenced. So that works out just fine. Now you can do more complicated searches in this. You can run double searches, so you would first search from the original filename, replace it with something new, and then you would run a search for an intermediate filename.

Let me show you what that looks like. I'll go ahead and add another criteria here and then I'll say, all right, I want to do String Substitution again, and this time I'm going to search from the intermediate filename and this time a want to replace the term goalie with hockey player let's say. Now this isn't a particularly useful search in my case, but still I can do it. I'll click on Preview and now notice that these filenames are becoming Sam as hockey player, like so. So lot of options available to me, you can ignore the case if you want to so you're not running a case-sensitive search so that you can either search for lowercase or uppercase characters.

Replace all if there is a letter, a single letter for example that you're searching for, then it's going to replace every single occurrence of that letter with something else. If you just want to replace the first occurrence of that letter you would turn this off, and then use regular expression. I'll show you how that works. That's a lot of fun. Anyway let's go ahead and click on Rename, in order to rename some of these images and there they are, Sam as hockey player 1 through 5. That's beautiful! All right, now then, here is something more complicated, and really, it is such a propeller-head feature, and I'm not going to provide a full-blown tutorial on how you work with regular expressions.

You can actually run a search for a regular expression on the web, just Google it, and you'll get all kinds of stuff and you can learn as much as you want to, there is quite a few good sites out there. But what regular expressions are? Is ways to search for a lot of different sorts of character strings at the same time. So for example let's scroll up the list here, and notice these images of Sammy with a butterfly on his face. They all start out B0000, so for four zeros, 4 and then either a 6 or a 7, and then that's it, nobody else sends with a 6 or a 7 that begins with a 4 and four zeros.

So of course if I didn't want to be a total geek, I could just go ahead and click on one of the Sammy's and Shift+ Click on the other and just replace those files with new names. That's a way to work. But let's say I'm just feeling totally geeked out man! So I'll press Ctrl+A, Command+A on the Mac to select all the thumbnails, I'll go up to the tools menu and I'll choose Batch Rename, and I'll say, you know what? Let's go ahead and get rid of this second substitution right there. We're just going to substitute from the original filename. And I know that I'm looking for the Bs, B00004, and then either a 6 or a 7, like so.

So when you are searching for one character or the other, you put them in parenthesis. You put a vertical bar between them and inside there is going to be 6 or 7 as that point and we'll replace this with Sam & butterfly, let's say. And then I'll go ahead and add a hyphen. That's a good idea and then I'll click on Preview and nothing is happening so here I am being such a smarty pants and yet it didn't work, why not? I'll click on the Close Box because I didn't say that I wanted to use a regular expression. That right there is a regular expression. If I don't turn on this checkbox it will get interpreted as standard text.

In other words, I'd actually have to find an open parenth, a 6, a vertical bar, a 7, and a close parenth. Now if I click Preview, notice that I replaced these guys, 6 through 7 with Sam & butterfly with the hyphens and because there were exactly ten images that had different digits associated with them, different last digits. Everything works out beautifully and I can click OK in order to acknowledge that that's going to work and then click Rename and I go ahead and automatically rename these guys. And the beauty of working this way is that now I can switch over to my JPEG files because I have that exact same naming convention going on, just press Ctrl+A, Command+A on the Mac in order to select all of the thumbnails, go up to tools, choose Batch Rename, and then re-run that exact same search. Click on Preview.

Just make sure it's going to work. It is, and so let's go ahead and rename again and we did it, see! So there are advantages to working in the geeked out way. So again if you want to learn more about regular expressions, there are all kinds of expressions that are out there, there's something like 11 different characters that you can use in specific ways like parenthesis and vertical bars and brackets and braces and periods and all this other stuff. Anyway, I'm going to go back to open_ org because I want to show you another thing that you could do. Let's go ahead and scroll all the way to the very end.

Actually where are these images I'm looking for? There are the towers. Notice that they begin L1030713, here's another way you can work. If you just want another random example of regular expressions, I'll press Ctrl+A, Command+A on the Mac to select all the thumbnails, go back up to the tools menu, choose Batch Rename, and I think you're going to enjoy this one a lot. I'm going to say L+, open square bracket, and let's say 0-9 which means a group of numbers and then I'll say, close square bracket and then I'll do a brace which is Shift+right brace, of course 2, 8 and close brace, L+(0-9){2,8}.

Now what in the world am I saying there? Well I'm saying, look for the character L of course, it's very important, and I went ahead and made it in uppercase cell so we want Ignore Case turned off because we are working case-sensitive here. And then we've got a group of numbers here and I'm saying, go ahead and replace that group of numbers and that string of numbers can be anywhere from 2 to 8 digits long. And so that should cover it pretty well and I'm going to go ahead and call this guy Seattle tower because it was some kind of tower in Seattle, I don't really remember what.

Click Preview and notice it just goes ahead and replaces those two but it replaces them with the exact same name, Seattle tower, which is not a good idea. All right, so I need to add some sort of sequence number to this group. What I can't do is just click Plus and say yeah, you know what? I want a sequence number right there, and it should just be like one digit and that's all I need because now if I preview I'm replacing a whole bunch of stuff. We're adding sequence numbers to every single filename. And notice that they are appearing after the extension, that's nice.

All right, so click Close in order to get rid of that. Go ahead and click Minus, and what I need to do is preserve the last number in that filename, whatever it was, either two or three as you can see, and so altogether what do we have? We've got 1, 2, 3, 4, 5, 6, so let's take that string value down to 6 so we're just replacing a string of number 2 to 6 characters long, and let's click on Preview and we will keep 2 and 3 afterwards, good. And I might as well add a hyphen so that we have a little bit of a divider and I'll click Rename and sure enough I just renamed those two files.

So again, you can get as geeked out as you want to people. Those are a few examples of how to do String Substitution including how to use regular expressions here inside Bridge CS5.

Show transcript

This video is part of

Image for Photoshop CS5 One-on-One: Fundamentals
Photoshop CS5 One-on-One: Fundamentals

195 video lessons · 73911 viewers

Deke McClelland
Author

 
Expand all | Collapse all
  1. 39m 52s
    1. Welcome to Photoshop CS5 One-on-One
      1m 49s
    2. Making Photoshop your default image editor
      7m 43s
    3. Installing the DekeKeys keyboard shortcuts
      8m 10s
    4. Remapping Mac OS shortcuts
      7m 37s
    5. Installing the Best Workflow color settings
      4m 31s
    6. The color settings explained
      6m 54s
    7. Loading the CS5 color settings in Bridge
      3m 8s
  2. 53m 36s
    1. There is nothing you can't do
      2m 1s
    2. The power of Photoshop
      4m 43s
    3. Duplicating a layer
      4m 49s
    4. Liquifying an image
      4m 43s
    5. Adding a layer mask
      5m 54s
    6. Loading an alpha channel
      7m 42s
    7. Selecting with Color Range
      4m 10s
    8. Making a Hue/Saturation layer
      2m 53s
    9. Luminance blending
      7m 21s
    10. Mask density
      5m 9s
    11. Making a knockout layer
      4m 11s
  3. 51m 23s
    1. The best way to work
      41s
    2. Setting General preferences
      5m 33s
    3. Changing the pasteboard color
      5m 41s
    4. File handling, performance, and units
      7m 25s
    5. Touring the Photoshop interface
      11m 5s
    6. Creating and saving a workspace
      7m 21s
    7. Changing settings and updating the workspace
      6m 4s
    8. Resetting the preferences
      7m 33s
  4. 2h 46m
    1. The amazing Adobe Bridge
      1m 17s
    2. Making a new image
      5m 11s
    3. Opening an image
      7m 7s
    4. Opening and closing multiple images
      5m 24s
    5. Opening a problem image
      4m 23s
    6. Adding file information
      8m 37s
    7. Introducing Adobe Bridge
      7m 37s
    8. A whirlwind tour of Bridge
      7m 21s
    9. Adjusting the interface and thumbnails
      8m 18s
    10. Using the full-screen preview
      8m 5s
    11. Rotating images on their sides
      5m 38s
    12. Assigning star ratings and labels
      8m 40s
    13. Filtering thumbnails in the Contents panel
      9m 13s
    14. Moving, copying, and deleting files
      6m 34s
    15. Creating and assigning keywords
      6m 38s
    16. Searches and collections
      7m 3s
    17. Batch-exporting JPEG files
      8m 57s
    18. Batch-renaming
      7m 15s
    19. String substitution and regular expressions
      8m 50s
    20. Grouping images into stacks
      7m 21s
    21. Comparing images in Review mode
      5m 58s
    22. Playing images in a slideshow
      4m 49s
    23. Customizing and saving the workspace
      7m 17s
    24. Using Mini Bridge in Photoshop CS5
      8m 36s
  5. 1h 1m
    1. Learning to swim inside an image
      37s
    2. The tabbed-window interface
      5m 19s
    3. Arranging image windows
      4m 26s
    4. Common ways to zoom
      5m 31s
    5. New zoom tricks in Photoshop CS5
      4m 24s
    6. Hidden old-school zoom tricks
      4m 34s
    7. Scrolling and panning images
      4m 8s
    8. Viewing the image at print size
      6m 42s
    9. The Navigator and "bird's-eye" scrolling
      2m 56s
    10. Nudging the screen from the keyboard
      2m 39s
    11. Scroll wheel tricks
      3m 41s
    12. The Rotate View tool
      3m 36s
    13. Cycling between screen modes
      6m 17s
    14. Using the numerical zoom value
      6m 14s
  6. 1h 6m
    1. Imaging fundamentals
      58s
    2. What is image size?
      7m 45s
    3. The Image Size command
      6m 0s
    4. Selecting an interpolation option
      4m 56s
    5. Upsampling versus "real" pixels
      5m 22s
    6. The penalty of pixels
      5m 35s
    7. Print size and resolution
      7m 26s
    8. Downsampling for print
      6m 39s
    9. Downsampling for email
      7m 28s
    10. Options for upsampling
      8m 13s
    11. Better ways to make a big image
      6m 1s
  7. 44m 43s
    1. Frame wide, crop tight
      1m 2s
    2. Using the Crop tool
      8m 8s
    3. Fixing out-of-canvas wedges
      5m 31s
    4. Crop tool presets
      6m 53s
    5. Previewing the crop angle
      4m 24s
    6. The Crop command
      4m 47s
    7. Straightening with the Ruler tool
      4m 18s
    8. Cropping without clipping
      5m 1s
    9. Perspective cropping
      4m 39s
  8. 1h 41m
    1. Making drab colors look better
      1m 20s
    2. Brightness and contrast
      4m 10s
    3. Adjusting numerical values
      4m 26s
    4. Introducing adjustment layers
      5m 17s
    5. Editing adjustment layers
      2m 51s
    6. Saving adjustment layers
      4m 35s
    7. Adding a quick layer mask
      4m 23s
    8. Introducing the Histogram
      4m 34s
    9. Working with the Histogram panel
      6m 27s
    10. Using Color Balance
      7m 18s
    11. Introducing the Variations command
      4m 51s
    12. Luminance and saturation controls
      3m 54s
    13. Fading a static adjustment
      3m 21s
    14. How hue and saturation work
      4m 28s
    15. Rotating hues and adjusting saturation
      6m 4s
    16. Creating a quick and dirty sepia tone
      4m 42s
    17. Adjusting hues selectively
      5m 32s
    18. The Target Adjustment tool
      4m 24s
    19. Photoshop CS5 Target Adjustment enhancements
      53s
    20. Adjusting the color of clothing
      8m 44s
    21. Enhancing a low-saturation image
      4m 23s
    22. Refining saturation with Vibrance
      5m 1s
  9. 1h 57m
    1. Photoshop versus the real world
      1m 21s
    2. Meet the selection tools
      10m 26s
    3. Marking the center of an image
      4m 9s
    4. Drawing a geometric selection outline
      4m 45s
    5. Blurring a selection outline with Feather
      6m 8s
    6. Copy and paste versus drag and drop
      5m 31s
    7. Creating a graduated selection
      4m 29s
    8. Aligning one image with another
      4m 45s
    9. Accessing the Move tool on the fly
      3m 34s
    10. Invert and Match Colors
      5m 4s
    11. Matching colors selectively
      3m 52s
    12. Feathering and filling a selection
      5m 14s
    13. Dressing up a composition with effects
      5m 34s
    14. The incredible image rotation trick
      2m 18s
    15. The Magic Wand tool
      4m 12s
    16. Tolerance and other options
      7m 7s
    17. Grow, Similar, and Inverse
      5m 39s
    18. Quick selection and the Magnetic Lasso
      7m 27s
    19. Evaluating a selection in Quick Mask
      8m 52s
    20. Saving and loading selections
      6m 14s
    21. Placing an image with a layer mask
      3m 23s
    22. Eliminating edge fringing
      7m 43s
  10. 1h 58m
    1. Brushing to correct
      56s
    2. How brushing works
      4m 52s
    3. Working with spacing
      7m 32s
    4. Changing size and hardness
      7m 45s
    5. The heads-up Color Picker
      7m 17s
    6. Flipping a mirror image
      3m 33s
    7. Setting the source for the History brush
      3m 42s
    8. Brightening details with the Dodge tool
      7m 49s
    9. Darkening details with the Burn tool
      3m 5s
    10. The Sponge tool
      4m 29s
    11. Backing off edits
      8m 4s
    12. Patching eye bags
      8m 57s
    13. Evening out flesh tones
      7m 23s
    14. Smoothing away whiskers
      7m 41s
    15. Reducing shadow noise
      7m 0s
    16. How healing works
      4m 40s
    17. The enhanced Spot Healing brush
      4m 52s
    18. Using the better Healing brush
      4m 23s
    19. Introducing the Clone Source panel
      3m 49s
    20. Cloning from one layer to another
      5m 30s
    21. Working with multiple sources
      4m 44s
  11. 1h 23m
    1. The layered composition
      1m 0s
    2. Making a new background layer
      6m 58s
    3. Working with "big layers"
      6m 24s
    4. Move, Duplicate, and Scale
      4m 11s
    5. Transforming a copy and repeat
      5m 15s
    6. Stacking order and eyedropping a layer
      5m 15s
    7. Adjusting multiple layers at once
      4m 22s
    8. Switching between layers
      4m 56s
    9. Making a digital star field
      5m 9s
    10. Blend mode and clipping mask
      4m 50s
    11. Dragging and dropping from your desktop
      4m 38s
    12. Black + Lens Flare = glow
      6m 16s
    13. Locking transparency
      5m 42s
    14. Adding gradient layers
      8m 12s
    15. Stacking an adjustment layer
      4m 12s
    16. Adding shadow and stroke
      6m 9s
  12. 1h 17m
    1. Outputting from Photoshop and Bridge
      1m 32s
    2. Printing an RGB composite
      5m 31s
    3. Customizing the subjective print file
      3m 15s
    4. Gauging print size
      5m 35s
    5. Scale, position, and page orientation
      5m 6s
    6. Three important printing curiosities
      4m 41s
    7. Introducing the Output options
      5m 34s
    8. Establishing a bleed
      5m 52s
    9. Using the Color Management options
      7m 21s
    10. Generating a PDF contact sheet
      6m 18s
    11. Creating a contact sheet template
      6m 8s
    12. Saving and opening a PDF contact sheet
      4m 18s
    13. Introducing the Web Gallery
      7m 53s
    14. Exporting and editing an HTML site
      3m 58s
    15. The Airtight Photocard site
      4m 56s
  13. 1h 9m
    1. Rules of the web
      1m 1s
    2. Introducing web graphics
      6m 59s
    3. A first look at Save for Web
      5m 47s
    4. Scaling a layered image versus a flat one
      7m 30s
    5. Incremental downsampling
      3m 1s
    6. Adding text, bar, and stroke
      4m 24s
    7. Assigning copyright and metadata
      6m 21s
    8. Comparing GIF, JPEG, and PNG
      4m 59s
    9. Determining the perfect JPEG settings
      6m 31s
    10. Saving metadata
      3m 52s
    11. Working with an unprofiled RGB image
      4m 35s
    12. Downsampling graphic art
      4m 49s
    13. Saving a GIF graphic
      6m 1s
    14. Antiquated GIF versus the better PNG
      4m 6s
  14. 1m 37s
    1. Until next time
      1m 37s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Photoshop CS5 One-on-One: Fundamentals.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.