Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator Change File Extension

I have a number of files that have the incorrect File Extension.


I would like to see if I could use Automator to check the file extension and change to the correct extension.


if I use the file -I command in Terminal I can see the files that have a incorrect extension, I would like to get Automator to look into my folders, subfolders and where it needs to change the extension.


Paul

Posted on Oct 2, 2019 2:06 PM

Reply

Similar questions

55 replies

Oct 20, 2019 2:24 PM in response to Paul1762

After rewriting this thing about five times, the code is in place, and it works briskly after I had to drop the AppleScript part of it. For some TBD reason, it is sending legitimate jpg and tif images to be renamed, so I have to peer into the traces to see what is actually going on. But images with mismatched mimetype and extensions are getting caught.


Stay tuned.

Oct 21, 2019 12:32 PM in response to Paul1762

Is it customary for your RAW image extensions to be capitalized, lowercase, or a mixture? The script is working correctly, but as it stands, RAW files are being renamed with lowercase extensions, and I can change that if you wish before I post it.


I added 24 files to three sub-directories totaling 773 MB of images. Eleven of those images were assigned bogus extensions, and the script caught all eleven and successfully changed the extensions. It successfully passes my test plan.

Oct 22, 2019 12:10 PM in response to VikingOSX

Viking,

I started to install the Homebrew Package manager and encounter the following error,


HEAD is now at 299bb1c25 Merge pull request #6628 from reitermarkus/automation-access

Error: /usr/local/Cellar is not writable. You should change the ownership and permissions of /usr/local/Cellar back to your user account:

sudo chown -R $(whoami) /usr/local/Cellar

Failed during: /usr/local/bin/brew update --force


any ideas?

Paul

Oct 22, 2019 1:13 PM in response to Paul1762

In the Terminal, check if /usr/local is present:

ls /usr/local


if it shows content, then you should be the owner before installing homebrew. This also sets the group to admin, which is what mine is set too. Skip the mkdir if /usr/local/bin already exists.

sudo chown -R $(whoami):admin /usr/local
mkdir /usr/local/bin


Now, reinstall homebrew, and it will use the /usr/local parent folder permissions when creating its sub-directories.

Oct 25, 2019 12:24 AM in response to VikingOSX

Viking,

I have now managed to install Xcode again and update this, I have now got as far as trying to reinstall homebrew... I think I have managed to complete the first steps...


that’s all I managed to complete last night... I am away for a week on business which I had to prepare for... will update you in a week...


thanks again...

Oct 25, 2019 4:25 AM in response to Paul1762

Thanks. Have firsthand knowledge of week-long business trips and the requisite preparation.


One of my own discoveries with a clean install of Catalina, is that if one types python3 in the Terminal, the operating system knows that it is not installed, because Xcode 11.1 is not installed, and instead, offers to install the companion Command Line Tools for Xcode 11. Thus, python3 is irrelevant — but you do get the compilation tools installed that Homebrew requires, without the 8GB Xcode 11.1 installation.

Nov 5, 2019 11:23 AM in response to VikingOSX

Viking,

I think I have now installed Homebrew... I am stuck now at this stage, what do I need to do here?


You will need /usr/local/bin in your shell PATH, so either in your ~/.bash_profile, or ~/.zshrc, you would do the following:

export PATH=".:/usr/local/bin:$PATH"
# gag Google analytics tracking
export HOMEBREW_NO_ANALYTICS=1


and for the current Terminal session to put this into effect:

source ~/.bash_profile or source ~/.zshrc


I have also download the script, how do I deploy this?


Paul

Nov 7, 2019 11:44 AM in response to Paul1762

One of the nasty things that HTML content may contain is   elements which is a non-breaking space character. Unfortunately, TextEdit can interpret HTML/CSS to an extent, and I believe copy/pasting the content that I typed in the previous post from this support community into the plain text dot-files is polluting them with those converted HTML   codes, and hence the Unicode \ufeff junk.


More work, but start over with new TextEdit sessions, and manually type what I have posted for each respective dot file. This eliminates the possibility of pollution from the clip board.


Type the following in the Terminal, followed by a return, to ensure that you are in your home directory before using the source command.


cd



Nov 7, 2019 1:12 PM in response to Paul1762

If your default shell is now Zsh, then ignore the ~/.bash_profile as Zsh won't read it anyway.


Once you have redone the content in /Users/paul/.zprofile and /Users/paul/.zshrc, just quit the Terminal application and let Zsh read the /Users/paul/.zprofile when Terminal is lauched again.


You will know what shell you are running by the following in the Terminal:


echo $SHELL


If your PATH is set properly, then you can get results from exiftool by asking it for its version:

exiftool -ver



Nov 7, 2019 2:09 PM in response to Paul1762

Ok. The PATH is getting set, and you are finding /usr/local/bin/exiftool, so life is good. I believe the episode with TextEdit strongly suggests that you need a proper Text editor. You will need to open the code that I posted on Google Drive, and I don't want TextEdit messing that up.


I recommend that you download the free trial of BBEdit. When the trial is over, it will continue to function as a proper text editor. During the trial, there may be updates, and upon trial conclusion, you can simply download yet another trial. This is what I do.


BBEdit will install into your /Applications folder. Once installed, right-click on it and choose Open from the secondary menu. A short verification progress bar will appear, and then hopefully you will get another panel with an Open button on it. Click that too. Now BBEdit can be used normally afterward without repeating this ritual.


Download the code I posted on my Google Drive account. It will go into your Downloads folder as img5.zsh.zip. Just double-click it to reveal img5.zsh. This is what you open with BBEdit, and will copy/paste into Automator as I outlined previously.

Nov 18, 2019 12:50 AM in response to Paul1762

Sorry Viking for not getting back...


i have installed the text editor you suggested... and have edit the files using your file... i still get the same error...


so i have deleted the files uninstalled xcode, and reinstall all... thats as far as i have managed to get too at this stage...


it must be something that I have done, or is doing...


paul

Nov 18, 2019 3:39 AM in response to Paul1762

Download this zprofile text file from my Google drive folder. Do the following in Terminal:

cd
cp ~/Downloads/zprofile .zprofile
cp .zprofile .zshrc


Now you have the two files without ever editing them. Quit Terminal, and relaunch it. The .zprofile should be read correctly by the Terminal when it launches. You should have a proper PATH statement, and prompt now.


Open the imgmv.zsh script in BBEdit. Follow my previous instructions for constructing the two-action Automator application.

Automator Change File Extension

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.