Jump to content
You must now use your email address to sign in [click for more info] ×

Recommended Posts

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

Link to comment
Share on other sites

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.

☛ 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

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.

 

Link to comment
Share on other sites

Assuming all files are in a folder, I would traverse (iterate over) those ...

  1. Read and keep the file name as a string
  2. 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
  3. Append the extracted last number to the front of the string ("number-")
  4. Rename the file via "mv" to the new generated file name string

☛ 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

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

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

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: 

image.thumb.png.014778215c305c1b39fe20b3d2db79e6.png

 

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:

image.thumb.png.9d784bc545e054c040ab2904444b4272.png

 

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. 

—— Gary ——

Photo/Designer/Publisher: Affinity Store, v2.1.1 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

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…

—— Gary ——

Photo/Designer/Publisher: Affinity Store, v2.1.1 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

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

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

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.

☛ 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

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

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

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.

—— Gary ——

Photo/Designer/Publisher: Affinity Store, v2.1.1 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

6 hours ago, R C-R said:

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.

☛ 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

14 hours ago, dedolightamericas said:

 

Screen Shot 2019-07-15 at 8.29.51 AM.png

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 ...

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!

☛ 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

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.

Windows 10 Pro (Desktop). Affinity Photo, Designer, Publisher 1.9.2

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.