userremoved

Q: Apple Script to rename images using CSV file

Hello, I have build a website using a Woocommerce for Wordpress. The site is going to have over 1200 images and they need to be renamed appropriately for each product. I've never used Apple Script before but after hours and hours of searching I have noticed people with similar issues have managed to solve the problem using AppleScript.

 

I have attached a screenshot of the CSV file first 20 files - also the images are all saved in a folder with the names _DSC7916 copy 2.jpg etc etc.

 

Hopefully my issue makes sense,

 

Old-Image-New-Image.jpg

MacBook Pro with Retina display, iOS 7.0.4

Posted on Dec 27, 2015 4:28 PM

Close

Q: Apple Script to rename images using CSV file

  • All replies
  • Helpful answers

first Previous Page 8 of 11 last Next
  • by Tony T1,

    Tony T1 Tony T1 Oct 18, 2015 1:25 PM in response to williamleon
    Level 6 (9,249 points)
    Mac OS X
    Oct 18, 2015 1:25 PM in response to williamleon

    1st post a few lines of what's in the file "statestudentnumberonly"

    Then the 2nd step is to debug using echo.

    Change

         mv "$OldImageName"  "Desktop/NEWFOLDER/$NewImageName"

    to

         echo mv "$OldImageName"  "Desktop/NEWFOLDER/$NewImageName" >> $HOME/Desktop/debug.txt

     

    and post a few lines of what you see in the debug.txt file created on the Desktop

  • by williamleon,

    williamleon williamleon Oct 18, 2015 1:37 PM in response to Tony T1
    Level 1 (4 points)
    iPhone
    Oct 18, 2015 1:37 PM in response to Tony T1

    It ran through without giving me an error but not able to locate any files who's names have been changed.

  • by Tony T1,

    Tony T1 Tony T1 Oct 18, 2015 1:46 PM in response to williamleon
    Level 6 (9,249 points)
    Mac OS X
    Oct 18, 2015 1:46 PM in response to williamleon

    Without seeing a few lines of the input file or what echo is showing as the output command, there's not a lot I can do, sorry.

  • by vnylund,

    vnylund vnylund Nov 2, 2015 4:38 AM in response to Tony T1
    Level 1 (0 points)
    Nov 2, 2015 4:38 AM in response to Tony T1

    Hi Tony!

     

    Sorry to be picking up this issue again, but I've been reading through the whole thread and after a while it's gets messy. I lost track of which step I should follow in order for it to work after trying several steps and changing back and forth of the AppleScript etc.

     

    If it's not too much to ask I would love some further help from scratch.

     

    I've created the .csv file and placed all images in a folder - How and where should I place these files?

    And what script am I supposed to write in the last step for the Shell Script? Please write the full code with clear marks where and what I need to change.

    As I've been trying several steps mentioned earlier in this thread the closest I've come in order for it to work is that the script runs without errors but nothing happens to the file names...


    Note that I have zero experience from using these tools in OS X so please use a language that I can understand

     

    Thank you very much in advance!

     

    (Sorry about the Swedish language in screenshot!)


    SS.png

  • by Tony T1,

    Tony T1 Tony T1 Nov 3, 2015 6:04 AM in response to vnylund
    Level 6 (9,249 points)
    Mac OS X
    Nov 3, 2015 6:04 AM in response to vnylund

    vnylund wrote:

     

    I've created the .csv file and placed all images in a folder - How and where should I place these files?

     

    The CSV file and the images don't need to be in the same Folder as the Script will ask for the CSV file and then will ask for the Folder with the images.

     

    Looks like what you posted should work, but, if as its not, please edit the script as follows (this is for debugging purposes):

      change:

         mv "$OldImageName" "$NewImageName"

      to:

         echo mv "$OldImageName" "$NewImageName" >> $HOME/Desktop/debug.txt

     

    then post a few lines of what's in the debug.txt file that's created on the Desktop.

  • by vnylund,

    vnylund vnylund Nov 3, 2015 6:21 AM in response to Tony T1
    Level 1 (0 points)
    Nov 3, 2015 6:21 AM in response to Tony T1

    Tony,

     

    Thanks for your reply!

     

    I made the changes as stated above but it doesn't generate any .txt logg.

     

    Please see attached screenshot.

     

    Thanks in advance for your further assistance!

     

    Screenshot.png

  • by Mark Jalbert,

    Mark Jalbert Mark Jalbert Nov 3, 2015 6:28 AM in response to vnylund
    Level 5 (4,649 points)
    Nov 3, 2015 6:28 AM in response to vnylund

    Note: the following line is missing the $ in the HOME variable and the quotes are unbalanced. The script will fail.

     

      echo "$OldImageName >> "HOME/Desktop/MissingFiles.txt"

     

    should be

     

        echo "$OldImageName" >> "$HOME/Desktop/MissingFiles.txt"

  • by vnylund,

    vnylund vnylund Nov 3, 2015 6:44 AM in response to Mark Jalbert
    Level 1 (0 points)
    Nov 3, 2015 6:44 AM in response to Mark Jalbert

    Mark,

     

    Thanks for your feedback.

     

    I made your requested change and also moved some files according to the script (I did some thinking of my own).

    So the script runs without errors now but it doesn't generate the change of the files names... So it runs the script but nothing happens.

    Please see attached screenshot.

     

    Thanks in advance for your further assistance!

     

    Screenshot.png

  • by Tony T1,

    Tony T1 Tony T1 Nov 3, 2015 6:56 AM in response to vnylund
    Level 6 (9,249 points)
    Mac OS X
    Nov 3, 2015 6:56 AM in response to vnylund

    vnylund wrote:

    I made your requested change and also moved some files according to the script (I did some thinking of my own).

    So the script runs without errors now but it doesn't generate the change of the files names...

    So it runs the script but nothing happens

     

    The change was for debugging purposes, not to move files.

    There should be a file on your Desktop named "debug,txt", please post a few lines from that file.

  • by vnylund,

    vnylund vnylund Nov 3, 2015 7:05 AM in response to Tony T1
    Level 1 (0 points)
    Nov 3, 2015 7:05 AM in response to Tony T1

    Tony,

     

    You are referring to my answer to Marks post. Please my answer to your post above.

    I made your change in the script but no .txt file was generated on my desktop. So I can't provide you with the data you're asking for, sorry!

  • by Tony T1,

    Tony T1 Tony T1 Nov 3, 2015 7:14 AM in response to vnylund
    Level 6 (9,249 points)
    Mac OS X
    Nov 3, 2015 7:14 AM in response to vnylund

    vnylund wrote:

     

    Tony,

     

    You are referring to my answer to Marks post. Please my answer to your post above.

    I made your change in the script but no .txt file was generated on my desktop. So I can't provide you with the data you're asking for, sorry!

     

    ok, first get the script back to where it was.

      change:

         echo mv "$OldImageName" "$NewImageName" >> $HOME/Desktop/debug.txt

      to:

         mv "$OldImageName" "$NewImageName"


    Now, before the if statement, add:

         echo mv "$OldImageName" "$NewImageName" >> $HOME/Desktop/debug.txt


    Is there a debug.txt file created on the Desktop now?

        

  • by vnylund,

    vnylund vnylund Nov 3, 2015 7:19 AM in response to Tony T1
    Level 1 (0 points)
    Nov 3, 2015 7:19 AM in response to Tony T1

    Like this? (Didn't generate the debug file)

     

    Screenshot.png

  • by Tony T1,

    Tony T1 Tony T1 Nov 3, 2015 7:34 AM in response to vnylund
    Level 6 (9,249 points)
    Mac OS X
    Nov 3, 2015 7:34 AM in response to vnylund

    I see now that you hard-coded the folder as the Documents Folder (sorry, I missed that before).

    In this case, then both the CSV file and the images need to be in the Documents Folder (and also the only Automator Action needed is the Run Shell Script Action).

  • by vnylund,

    vnylund vnylund Nov 3, 2015 7:43 AM in response to Tony T1
    Level 1 (0 points)
    Nov 3, 2015 7:43 AM in response to Tony T1

    I see.

     

    Tried to make it work but same problem still occurs. The script runs without any problems but the action is not generated so the names of files is not being changed...

     

    Screenshot.png

  • by Tony T1,

    Tony T1 Tony T1 Nov 3, 2015 7:48 AM in response to vnylund
    Level 6 (9,249 points)
    Mac OS X
    Nov 3, 2015 7:48 AM in response to vnylund

    >vnylund wrote:

    >I see.

    >Tried to make it work but same problem still occurs.

    >The script runs without any problems but the action is not generated so the names of files is not being changed...

     

    Can you post a few lines of the CSV file?

first Previous Page 8 of 11 last Next