dedolightamericas Posted July 15, 2019 Share Posted July 15, 2019 I have more than 800 photos from products for a catalog. The WEB programer! ask me to index the pics from product and 1 - 2 - 3 for different angles of each product. example... I have DSC-1-1 DSC-1-2 DSC-1-3 Now the little fairy wants my images with the index in the front. 1- DSC-1 2- DSC-1 3- DSC-1 I have more than 800 product codes each with at least 3 to 4 different images I need some guru to let me know how can I delete the -1, -2 etc from the end and paste it at the beginning with out change the product code Quote Link to comment Share on other sites More sharing options...
v_kyr Posted July 15, 2019 Share Posted July 15, 2019 On which OS are you working and what scripting capabilities do you have there? - In order to rename 800 files that way I would build a custom renaming script for that task, or use some appropriate already available third party tool for the job. Quote ☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan ☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2 Link to comment Share on other sites More sharing options...
dedolightamericas Posted July 15, 2019 Author Share Posted July 15, 2019 OSX, dear V-KYR I have looked into Automator, but I can only find a way to rename the whole file name, I was looking into something to respect a part to the file name while change the thing need to change. 5 minutes ago, v_kyr said: On which OS are you working and what scripting capabilities do you have there? - In order to rename 800 files that way I would build a custom renaming script for that task, or use some appropriate already available third party tool for the job. Quote Link to comment Share on other sites More sharing options...
dedolightamericas Posted July 15, 2019 Author Share Posted July 15, 2019 Just now, dedolightamericas said: OSX, dear V-KYR I have looked into Automator, but I can only find a way to rename the whole file name, I was looking into something to respect a part to the file name while change the thing need to change. Quote Link to comment Share on other sites More sharing options...
Move Along People Posted July 15, 2019 Share Posted July 15, 2019 - Quote Move Along people,nothing to see here Link to comment Share on other sites More sharing options...
v_kyr Posted July 15, 2019 Share Posted July 15, 2019 Assuming all files are in a folder, I would traverse (iterate over) those ... Read and keep the file name as a string Read the last number part from that file name string keep it in a var and then also remove the end characters ("-1|-2|-3 ...") part from it - Regular Expressions are also helpful for find/replace on a string here Append the extracted last number to the front of the string ("number-") Rename the file via "mv" to the new generated file name string Quote ☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan ☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2 Link to comment Share on other sites More sharing options...
John Rostron Posted July 15, 2019 Share Posted July 15, 2019 I use Bulk File Rename for that sort of thing. I'm sure that it would do what you need. It includes adding and removing suffixes and prefixes as well as regular expressions. John Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
dedolightamericas Posted July 15, 2019 Author Share Posted July 15, 2019 All these commands are withing Automator interface or should I need to write a script for that? Quote Link to comment Share on other sites More sharing options...
GaryLearnTech Posted July 15, 2019 Share Posted July 15, 2019 Another approach, since @dedolightamericas is on a Mac, would be to use a utility such Better Rename to handle the renaming. You can get it from the Mac App Store or direct from the publisher (where a free trial is available). You have the choice of many different rule types available and can see a live preview of the results you'd get when you finally tell it to proceed. It looks to me as if you'll have to break this down into batches due to slight variations in the naming, such as single digits versus double digits being adjusted. This screenshot shows the first step I'd use, based on your initial sample. Read the screenshot from left to right: The second step would use the same command to exchange the first two characters to put the numeral first, followed by the hyphen. These steps can be built up and run as a single batch, so adding the second step under the first one in the left hand column would look like this, with the preview of the final renaming in the right hand column: When it runs, it's very fast. I used this about 18 months ago to work through an old set of clip-art CD's that I had copied onto an external USB 3 disk. As with this, I had had to break the job down into batches, but it got there. Sets of steps, such as shown above, can be saved as presets and easily recalled in the future, rather than rebuilding from scratch. ashf and dedolightamericas 2 Quote —— Gary —— Photo/Designer/Publisher: Affinity Store, v2.4.n release Mac mini (M1, 2020), 16GB/2TB, macOS Ventura 13.4.1(c) • MacBook Pro (Intel), macOS Ventura • Windows 10 via VMware Fusion • iOS: current release Link to comment Share on other sites More sharing options...
dedolightamericas Posted July 15, 2019 Author Share Posted July 15, 2019 You are a life saver, the free trial only allows to rename 10 files at a time... since I hope this is only one task to perform, I will stick to the free trial... THANKS! GaryLearnTech 1 Quote Link to comment Share on other sites More sharing options...
GaryLearnTech Posted July 15, 2019 Share Posted July 15, 2019 Glad to help. Watch out for the occasional promo where the price is dropped. You can see the price history here for the Mac App Store version. Since you can't predict jobs like this, it's worth having in your toolbox even if only for once or twice a year - and if you can pick it up cheap… Quote —— Gary —— Photo/Designer/Publisher: Affinity Store, v2.4.n release Mac mini (M1, 2020), 16GB/2TB, macOS Ventura 13.4.1(c) • MacBook Pro (Intel), macOS Ventura • Windows 10 via VMware Fusion • iOS: current release Link to comment Share on other sites More sharing options...
John Rostron Posted July 15, 2019 Share Posted July 15, 2019 Bulk File Rename would not work for you as it is Windows only. I did use Better File Rename for Windows and it worked well, but I found Bulk File Rename easier o use. John Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
v_kyr Posted July 15, 2019 Share Posted July 15, 2019 1 hour ago, dedolightamericas said: All these commands are withing Automator interface or should I need to write a script for that? What I suggested are instead more using some common language (bash, perl, python ... etc.) scripts than Automator based. Though there are for sure also ways to do it with Automator. All of the above named scripting languages support regular expressions, which are handy for extracting/stripping/appending/including portions of characters in a string (the file name string). - Perl for example has a "rename" command which can deal with regexp, python is also powerful in that regard. - It depends on what you personally feel more comfortable with here, namely using some shell based script processing or some GUI tool instead. There are also Mac desktop related ways to do so, in general there are many ways which lead to Rome. Quote ☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan ☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2 Link to comment Share on other sites More sharing options...
R C-R Posted July 15, 2019 Share Posted July 15, 2019 For Macs, I am surprised nobody has mentioned the built-in batch rename feature. How to Batch Rename Files on Mac OS X Easily from Finder GRH 1 Quote All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 Affinity Photo 1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7 Link to comment Share on other sites More sharing options...
GaryLearnTech Posted July 15, 2019 Share Posted July 15, 2019 32 minutes ago, R C-R said: For Macs, I am surprised nobody has mentioned the built-in batch rename feature. How to Batch Rename Files on Mac OS X Easily from Finder I took a quick look at that first, but reckoned you couldn't do exactly what the OP wanted. It is certainly a powerful feature though, that could be better known. Quote —— Gary —— Photo/Designer/Publisher: Affinity Store, v2.4.n release Mac mini (M1, 2020), 16GB/2TB, macOS Ventura 13.4.1(c) • MacBook Pro (Intel), macOS Ventura • Windows 10 via VMware Fusion • iOS: current release Link to comment Share on other sites More sharing options...
dedolightamericas Posted July 15, 2019 Author Share Posted July 15, 2019 that feature does not let you choose a couple of characters and move them to the start of the file name, or I am rung.? Quote Link to comment Share on other sites More sharing options...
v_kyr Posted July 16, 2019 Share Posted July 16, 2019 6 hours ago, R C-R said: For Macs, I am surprised nobody has mentioned the built-in batch rename feature. How to Batch Rename Files on Mac OS X Easily from Finder Then you didn't read and looked carefully through posts ... 9 hours ago, v_kyr said: There are also Mac desktop related ways to do so, in general there are many ways which lead to Rome. Mac desktop R C-R 1 Quote ☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan ☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2 Link to comment Share on other sites More sharing options...
v_kyr Posted July 16, 2019 Share Posted July 16, 2019 14 hours ago, dedolightamericas said: AFAI recall Perl is preinstalled on OSX systems and can be used right out of the box in a terminal window. So the below example perl script would work on filenames like shown in your screenshot. $ ./batchrename.pl *.jpg You gave 4 command-line file arguments: renaming DT12-1-05.jpg to 05-DT12-1.jpg renaming DT12-4-05.jpg to 05-DT12-4.jpg renaming DT13-1-01.jpg to 01-DT13-1.jpg renaming DT13-1-02.jpg to 02-DT13-1.jpg The "batchrename.pl" Perl script: #!/usr/bin/perl -w #----------------------------# # PROGRAM: batchrename.pl # #----------------------------# $numArgs = $#ARGV + 1; print "You gave $numArgs command-line file arguments:\n\n"; foreach $argnum (0 .. $#ARGV) { print "renaming $ARGV[$argnum] to "; $was = "$ARGV[$argnum]"; $filename = "$ARGV[$argnum]"; $tmp = $filename; $tmp =~ /-(\d\d)\.jpg/; $num = $1; $filename =~ s/-(\d\d)\.jpg/\.jpg/; $newfilename = "$num-$filename"; print "$newfilename\n"; rename ( $was, $newfilename ) unless $was eq $newfilename; } What the above script does is matching and remembering the last number part -##.jpg from a JPG file name like "DT12-1-05.jpg" in a string, then in a second step it substitutes and replaces in a filename string "-##.jpg" with ".jpg" and finally renames a file to a new composite filename, where the number part is placed at front. For example ... DT12-4-05.jpg --> 05-DT12-4.jpg The perl script file ... batchrename.pl In order to use that perl script you best copy it into the folder where the JPG image files reside and then give it executable rights so you can call it and pass the files to it, aka ... $ chmod +x batchrename.pl $ $ ./batchrename.pl *.jpg Good luck! Quote ☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan ☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2 Link to comment Share on other sites More sharing options...
Gradient_Phil Posted July 16, 2019 Share Posted July 16, 2019 For Windows also...I'll give a nod toward "Advanced Renamer" - comes in a portable version (so doesn't need to be installed) Using the replace function is quite easy (online tutorials / examples) and there is an undo feature if you screw it up. One thing I like about it - you can save the renaming function to use again. Quote Windows 10 Pro (Desktop). Affinity Photo, Designer, Publisher 1.9.2 Link to comment Share on other sites More sharing options...
ashf Posted July 16, 2019 Share Posted July 16, 2019 I would recommend Better Rename too. They hold a sale(80-90% off) once a year or so. So keep eye on it.http://appshopper.com/mac/utilities/better-rename-10 Quote Link to comment Share on other sites More sharing options...
Wosven Posted July 16, 2019 Share Posted July 16, 2019 On Windows there's also the versatile Ant Renamer that I use to rename files given by clients or Rename RegEx that can be used in a right-click menu and that I use to do the above. Quote Link to comment Share on other sites More sharing options...
CLC Posted July 16, 2019 Share Posted July 16, 2019 The best on Windows is imo the Multi-Rename Tool in Total Commander. Check it out... Images courtesy of HowToGeek Quote Why relying on your users to report errors is the dumbest thing you’ll ever do Link to comment Share on other sites More sharing options...
CLC Posted July 16, 2019 Share Posted July 16, 2019 For OSX, easiest way to batch rename files is to use standard finder rename... Images courtesy of OSX Daily You can use the Format dropdown menu item to customize the output. For even advanced renaming, you can use this Automator Tool How-To from OSX Daily: Quote Why relying on your users to report errors is the dumbest thing you’ll ever do Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.