Filenames are numerical code- need last four #'s to be the first four #'s

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!

This might help:
var theFolder = Folder.selectDialog("select the folder containing the images to be renamed");
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
Edit: Actually it should include some function to ascertain that the files are indeed jpgs or at least retain the original suffix.
Still if the folder contains only jpgs it should work.

Similar Messages

  • I have 91 file that are pdfs i need to make searchable what is the best way of doing this

    help
    i have 91 file that are pdfs i need to make searchable what is the best way of doing this

    Hi ismaelr61128862,
    I would recommend you to try Advanced search option of Acrobat software, Go to Edit and then Advanced search.
    Hope that helps. In case you have any further questions please provide sufficient amount of details so that i can assist you more accurately.
    Regards,
    Rahul

  • HT5312 I have forgotten the answers to my apple security questions. I have tried several times but just cant get through and I need to make a purchase for the first time

    I have forgotten the answers to my apple security questions. I have tried several times but just cant get through and I need to make a purchase for the first time

    I am having the same problem. I know my apple ID and password but do not remember my security questions. How do you go about changing the security questions? Please help.
    Thanks.

  • How long does it need to charge iphone 5 for the first time?

    Does anyone knows how long does it need to charge iphone 5 for the first time?
    Message was edited by: Islius

    Until it reads 100%

  • CR 2010 - Need to limit records returned to the FIRST ONE OR TWO

    I need a way to limit the data returned in a subreport to just the first one or two records (depending on the report requirements). The data is sorted by Date DESC and I only want the latest one or two recs. Can someone please tell me how I can do that?
    Thanks!

    Well, you can enter a suppression formula for the details section of the subreport like this:
    Recordnumber > 2 //
    This will display the two most recent records in the subreport.
    -Abhilash

  • Coder needed to wrap my .jar using the JavaFX Packager Utility

    Hello-I am not a coder. I am looking for a programmer who is able to wrap my .jar using the JavaFX Packager Utility. I would like to upload my app to the Mac App Store also and need assistance doing that.
    Please contact me for more details if you are able to do one or both of the above.
    Thank you,
    Jeff
    Edited by: 929408 on Sep 9, 2012 9:16 PM

    Ok. Please let me know when you are able to upload the .jar I have (packaged) to the Macintosh App Store if you would. Do you need a way to contact me? I don't know if I am able to place my email or main website here, and I don't check here often. We can work out a payment arrangement. Thank you.

  • I have a mac mini server, all clients are lion and need to reinstall OSX10.6b on the server, there is not remote install on lion clients, any work arounds?

    The onjly thing I can think of is dual boot one client machine in to OSX10.6, but is there a anther work around?

    dmason wrote:
    I had this problem as well. I was under the gun on time and just purchased it anyway. After installation I contacted support and they refunded me the amount.
    You should have a backup of your servers regardless of circumstances. You would then be able to restore the server software.
    When Apple repair machines they will often just swap it or swap the hard disk and will not make any effort to transfer your files. They assume you are doing a backup. Anybody running servers absolutely has a responsibility to ensure they have aduequate backups even more than 'normal' users. While Time Machine may not be wholely suitable for backing up servers Time Machine is so simple even normal users can use it and therefore no longer have any excuse for not doing backups.

  • HT4623 My 5.1.1. 28.6 Gb IPad crashes about every 5 minutes or so it doesn't matter what I am doing, whether it is fully charged, plugged in or needing a charge.  It is the first version, is it possible I need to replace it?

    I have had my iPad for several years and recently it has started crashing for no reason, I am wondering if I need to replace it of if there is a fix. It doesn't matter if it has a full charge or if the charge is low. I have noticed that the battery does not hold a charge for very long now so maybe the battery is going bad? Any thoughts?

    It's possible that the battery needs to be replaced. If you bought one of the original iPads, it could be close to four years old now so the battery might be bad.
    Have you tried any basic troubleshooting steps? Sometimes closing Apps and resetting the device can help. Clearing Safari wouldn't be a bad idea either.
    Go to Settings>Safari>Cookies and Data.
    In order to close all apps, Tap the home button once. Then tap the home button twice and the recents tray will appear at the bottom of the screen. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button twice.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    Apple has has a battery replacement policy that you can look into. I would make an appointment at an Apple Store and ask a Genius to look at your iPad and see if he/she can recommend something different or maybe even restore the device for you to get it back to good running condition again.
    Apple - Batteries - Battery Replacement

  • I just purchased a lightning sd card reader for my iPad, but it does not fit..it's for fourth gen...opps..I've now had to order the camera kit for third gen model...will I need both or do I return the first one

    Hi i just purchased an sd card reader but it's for fourth gen iPad...pops. I've now ordered the camera kit for the third gen ....do I need both somehow or do I just return the lightening ad reader I purchased first. I rang apple support and swear I was told keep both, but if the camera kit is all I need...I don't see the point in keeping the fourth gen one, since it won't fit? Confused...ita a fourteen day refund so I need to act fast...any help?

    There's no reaso to keep the Lightning version if your iPad can't support it. Unless you have some other devcie that can use it, like an iPad Mini or an iPhone 5.
    Otherwise return it.

  • I have set a new password today and i cant remember it cause the password i used to get access to my phone is a very hard one to remember i need som help cause this is the first time ever i have encounter

    if anybody can help i would appriecent it cause earlier this morning a deaf guy came across my phone and got access to it so i changed it a few times till i decided to create a hard password that nobody cant remember but since i was being a dumbasss for it i guess its my fault

    LOST PASSCODE
    You should be able to remove the passcode by restoring the device.
    Connect the device to the computer with which you normally sync and open iTunes.
    Note: If iTunes prompts you to enter the passcode, try another computer that you have synced with. Otherwise, go to "If you have never synced your device with iTunes", below.
    Right-click the device in the left column and select Back up.
    When the backup is complete, select Restore.
    When finished, restore from your most recent backup.
    Otherwise read this
    If that doesn’t work  you will need to perform a factory restore to remove it. Or read:
    Enter Wrong passcode
    http://support.apple.com/kb/ht1212

  • How long do I need to charge my phone for the first time?

    How long should I charge it before using? Anyone knows?

    Hi Virginia,
    It's probably best to just let it charge to 100%, however, if you needed to use it before it got to 100%, it won't hurt anything to do so.
    Cheers,
    GB

  • Printer owner want to reset code eprint and use with another account (the first is lost)

    how reset serial to use eprint printer with a new account?
    The old account is lost (not responding with registered mail)
    Thanks

    You can disable Web Services and then enable Web Services to get a new code to set up your printer's email address at ePrintCenter.com.  For more information on getting started you can go to this link: http://h30495.www3.hp.com/help#getting_started.gs-support-apps-eprint
    I am an HP employee

  • HT1498 I rented a movie last night and it downloaded the first 11 minutes (while we watched) then errored out with a message saying try again later.  We tried again later (for two hours!) no help.  How do I contact Apple for a credit?

    I was able to watch other content (including HD Previews of movies we hadn't purchased) os the network connection shouldn't have been the problem.  Just a spinning wheel and Rumplestiltzken turning my time into Apple's gold.  Now I am on the support pages and can't find a simple selection to request a credit for the movie we won't get to watch because the 24 hour clock started when we started watching it and is now at about 10 hours with me just arriving at work.  I also considered pulling it down to my MB Pro, but found out that since I started the download on my Apple TV, if I wanted the same movie on my MB, I would have to pay for it again... I am less than pleased so far with Apple TV.

    Okay, so istumbler says my connection goes to yellow when I go to the Aple TV location, but my internet speed is greatly increased tonight (20Mbps on speedtest.net near the router and 15.49Mbps at the Apple TV).  Upload is unchanged at a little under 1Mbps).  I did manage to get the Apple Contact location and I am sure they will post a credit for the movie (since their logs will show repeated attepts to download and no joy, although we both know they won't go to the trouble to look at them).  As far as I'm concerned, it was a one-time problem and until it happens again to me, I will remain convinced it was on their end of the connection or in between (although that was unlikely).  I've been administering and managing netowrks for over 20 years and am pretty confident that the connection on my end was working.

  • BULK IMPORT ONLY LOADS THE FIRST FOUR DIGITS FOR THE SIC CODE

    Hi,
    The issue is: DNB enrichment file has 8 digits SIC codes, but oracle bulk import only loads the first 4 digits and ignore the last 4. Just would like to whether it will be possible to import all the 8 digits of SIC code.
    Thanks and regards,
    Hareesh

    I solved the problem by using destroy() method instead of finally block. Thanks,anyway,Jimmy.

  • I need a 3-inch top margin on the first page of my letter and a 1-inch top margin on subsequent pages. How can I do this?

    This is so easy in Word but I have spent 2 hours trying to figure it out in Pages. To print on my boss' stationary I need a 3-inch margin on the first page and a 1-inch top margin on the subsequent pages. When I change the top margin on page 2 in Inspector, it changes the top margin on page 1 to 1-inch as well. In Word this is an intuitive, 2-step process.

    Hi Dan,
    Don't confuse "intuitive" with "what I'm used to."
    Pages has "Document" margins, which apply to all pages of the document, and "Layout" margins, which may be set to provide additional margin space in a layout.
    Start by setting the Document margins to 1" all around. This is the default setting for the (word processor) Blank templates. You can check it (and adjust it if necessary) in the Inspector. Open an Inspector window (View > Show Inspector). Choose the Document Inspector (first button).
    Switch to the Layout Inspector (second button). Remember that you already have a 1 inch top margin, so to produce a 3 inch margin before the beginning of this layout, you'll need to set a 2 inch Layout margin "Before" the layout.
    Hmmm... Depending what you're defining as 'steps' for the process in word, and considering that the document margins in Numbers are preset to 1" all around, this appears to be a 1-step process in Numbers:
    Step 1: Set the "Before" Layout margin to 2 inches.
    Done.
    Regards,
    Barry

Maybe you are looking for