🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.photoshop.scripting
6 messages
6 total messages Started by Ray1292 Tue, 24 Mar 2009 02:41
Filenames are numerical code- need last four #'s to be the first four #'s
#238
Author: Ray1292
Date: Tue, 24 Mar 2009 02:41
13 lines
1071 bytes
How do I switch the .jpg of numbers to the beginning of filenames?

I have several hundred files whose filenames have three sets of numbers separated by underscores.

Unfortunately, the last four numbers need to be placed at the beginning of the filenames. This is to establish chronology.

The current number sequence is: site number, date, number of the jpg

The desired number sequence is: jpg number, site number, date.

".jpg" would still be the last entry.

Thanks for any help!
Re: Filenames are numerical code- need last four #'s to be the first four #'s
#241
Author: christoph_pfaffenbichler
Date: Tue, 24 Mar 2009 09:11
31 lines
1232 bytes
This might help:


 
var theFolder = Folder.selectDialog("select the folder containing the images with paths"); 

if (theFolder) { 

   var theFiles = theFolder.getFiles(); 

   for (var m = 0; m < theFiles.length; m++) { 

      var theName = theFiles[m].name; 

      var theLastNumbers = theName.slice( theName.lastIndexOf("_") + 1, -4); 

      var theRest = theName.slice(0, theName.lastIndexOf("_")); 

      theFiles[m].rename(theLastNumbers + "_" + theRest + ".jpg") 

      } 

   }; 

else { 

   alert ("no selection") 

   };

use it at Your own risk
Re: Filenames are numerical code- need last four #'s to be the first four #'s
#242
Author: Ray1292
Date: Tue, 24 Mar 2009 11:34
1 lines
703 bytes
Where does all this code get pasted in? First time I've done this.
Re: Filenames are numerical code- need last four #'s to be the first four #'s
#243
Author: christoph_pfaffenbichler
Date: Tue, 24 Mar 2009 11:47
4 lines
1061 bytes
Paste it into a new file in ExtendScript Toolkit and save it as a jsx-file. (ExtendScript Toolkit should have been installed when You installed Photoshop.)
You can run it by hitting the play-button in the window�s upper bar or place it in Photoshop � Presets � Scripts.
But it doesn�t strictly belong to Photoshop as it does nothing within that program.
Please try it on a duplicate-folder first for testing-purposes.
Re: Filenames are numerical code- need last four #'s to be the first four #'s
#247
Author: christoph_pfaffenbichler
Date: Tue, 24 Mar 2009 15:12
2 lines
723 bytes
Dang, that�s cool!
(And � to me at least � still pretty mysterious.)
Re: Filenames are numerical code- need last four #'s to be the first four #'s
#246
Author: xbytor
Date: Tue, 24 Mar 2009 21:52
5 lines
853 bytes
Here's a different way to get the new file name from the old file name:

newName = oldFile.name.replace(/(\d+_\d+)(_)(\d+)\.jpg/, "$3$2$1.jpg");

-X
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads