![]() So use your regexp for matching, put brackets around the relevant blocks and do something like ss.\1.\2.(and so on)įor your replacement pattern. The whole pattern in thus replaced by XYZ.png. Here, the XYZ is matched by the expression in brackets and can be accessed using \1 in the replacment string. Here's a simple example: echo "ScreenShotXYZ.png" | sed "s/ScreenShot\(.*\)\.png/\1.png/" In your REGEXP pattern you can mark seperate groups by surrounding them with brackets (), in most situations you will have to escape them by () and access these parts in the replace pattern by using #, where # is the number of the subgroup starting from 1. ![]() sed will read from stdin, search ( s command) for pattern and replace it with REPLACE. You would do something like this echo $i | sed "s/PATTERN/REPLACE/" You can use stream editor sed to match and substitute using regular expressions. The end goal, is a bash script that when run will rename ALL files at the above mentioned path to the new format listed. I am not sure about the hour of the time, it may be safest to assume possible 2 digits on all chunks of the time, so 1.14.29 and 01.15.29 ss.08-02-12-01.15.29-AM.png So far, this is all I can come up with, but done know how to karen wrap the expression and then get that to a file rename in the format I desire: for i in * do I was once told, not to do a for loop against an ls so I am trying globbing this time around. Here are some examples of the filenames: Screen Shot at 1.15.29 AM.png I would like to rename any of them that sit at path /Users/me/desktop. Hello, Mac OS X takes screen shot's in a very long format of filename.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |