Apple Script with M1 Chip

My MacBook Pro died and I replaced it with MacBook Air with M1 chip. I have a couple Apple Scripts to move files from between folders. The scripts do not work in the new MacBook. Is there something I need to do differently or is this a bug?


Thanks for any help.

John

MacBook Air (2020 or later)

Posted on May 12, 2022 4:38 AM

Reply
Question marked as Top-ranking reply

Posted on May 12, 2022 8:03 AM

I pasted your script in ScriptEditor.


I created a folder "A" with files "a" and "b".

I created an empty folder "B".


In my desktop I createad a text file with two lines with the names of the files.


I started your script, selected the file containing the list, selected the origin folder, selected the destination folder.


It worked as expected.


Note: the first thing I saw was a dialog saying that the script wanted to access files in the Desktop. I allowed it.

Without that, it would not have worked, of course.


So the script does work in Monterey. Now we need to try and figure out why it is not working for you.


Are you launching the script from Script Editor? From Automator? Or as an application on its own?

Similar questions

39 replies

May 13, 2022 10:04 AM in response to VikingOSX

I couldn't figure out how to attach a sample file with the header and three records so I did a copy and past below. The records with retouch are throughout the file. For example on a file with 700 records there might be 40 with a retouch indicator and they are not all together so there can be blanks in that field between them. Many of the fields are blank but there is always a tab between the fields. Hopefully this is good enough. If not let me know and I'll try something else.

Thanks for all you are doing.


SequenceNumber FirstName LastName StudentID Teacher Grade HomeRoom Custom1 Custom2 Custom3 Custom4 P1 Q1 P2 Q2 P3 Q3 P4 Q4 Retouch Spray FileName GSBR

00001 John Staff H3 G_G_5766.jpg

00002 Paul Albinger 11 R IMG_5797.jpg

00003 George Polemeni 10 IMG_5800.jpg



[Personal Information Edited by Moderator]


May 13, 2022 10:25 AM in response to JB001

The data was in fact screwed up so here it is again with very obvious test data in the fields.


SequenceNumber FirstName LastName StudentID Teacher Grade HomeRoom Custom1 Custom2 Custom3 Custom4 P1 Q1 P2 Q2 P3 Q3 P4 Q4 Retouch Spray FileName GSBR

00001 John Nobody 00000 Staff AAAAAAAAAA Z 1 IMG_7839.jpg

00002 Paul Nobody 00000 Myteacher 11 AAAAAAAAAA B 1 K 1 P 1 R IMG_7836.jpg

00003 George Nobody 00000 Myteacher 10 AAAAAAAAAA B 1 IMG_5800.jpg

00004 Ringo Nobody 00000 Staff AAAAAAAAAA Z 1 IMG_7874.jpg

00005 Deb Nobody 00000 Myteacher 9 AAAAAAAAAA B 1 K 1 P 1 R IMG_7856.jpg

00006 George Nobody 00000 Myteacher 10 AAAAAAAAAA B 1 IMG_7834.jpg

May 13, 2022 12:39 PM in response to JB001

I have set up a Numbers spreadsheet with all of your fields and just test data in the Retouch and Filename fields. Exported as TSV and the current AppleScript iteration gets the first Retouch "R" entry and returns the filename, but does not get the 2nd "R" in the data or its associated filename. Is the Retouch field either an "R" or blank?


Some Friday evening teeth gnashing while debugging here…🤓

May 14, 2022 6:41 AM in response to VikingOSX

This is the error I received:


error "Can’t make item 9.22337203685478E+18 of {\"00002\", \"Paul\", \"Nobody\", \"00000\", \"Myteacher\", \"11\", \"\", \"\", \"\", \"\", \"AAAAAAAAAA\", \"B\", \"1\", \"K\", \"1\", \"P\", \"1\", \"\", \"\", \"R\", \"\", \"IMG_7836.jpg\", \"\"} into type text." number -1700 from item 9.22337203685478E+18 of {"00002", "Paul", "Nobody", "00000", "Myteacher", "11", "", "", "", "", "AAAAAAAAAA", "B", "1", "K", "1", "P", "1", "", "", "R", "", "IMG_7836.jpg", ""} to text




May 14, 2022 7:25 AM in response to JB001

I copied the exact code that I pasted this morning (2022-05-14) back into the Script Editor. Then I added the exact data elements from your error post to my Numbers spreadsheet and exported that as a revised TSV document. The AppleScript ran exactly as it did before my post — correctly, and without any errors.


This suggests that either you did not copy and paste the entire AppleScript, or there may be something in your TSV that is introducing errors that I cannot reproduce here. Are you on macOS 12.3.1?



May 14, 2022 10:39 AM in response to VikingOSX

Now it's my turn for teeth gnashing.

I thought it might be my MacBook so I've redone everything, several times, on my iMac and I can't get it to run.

I copied the test data I provided above into a Numbers file and exported it as TSV the way you did. I've double checked that I have copied the entire script, several times. It stops on the first record with an "R" in the Retouch column. I even tried rearranging the rows to see what would happen and no matter which record has the R it stops on the first one it hits.

It is working on your computer so I'm obviously missing something here but I am at a loss. I even tried to run it using copies of live data and got the same error. UUGGGHHH!!

I'm running an iMac (Retina 5K, 27-inch, Late 2015) macOS Monterey Version 12.3.1 and a

Apple 13.3" MacBook Air M1 Chip with Retina Display (Late 2020) macOS Monterey Version 12.3.1

Script Editor Version 2.11 (227)

May 14, 2022 11:50 AM in response to JB001

I am running this AppleScript directly from Script Editor, and not from Automator's Run AppleScript action, or in the Terminal via osascript (that also works correctly). All of my Numbers cells are text format, and none of the column data is quoted, or contains an embedded tab in the data items within the spreadsheet. Ensure that your data is in all 23 correct columns and your header items have no trailing space. Export to TSV as UTF-8. Preface it with an underscore so you won't have to scroll to locate it in the File chooser.


Without changing the TSV, the images, or the AppleScript, I also just ran this on my 2020 27-in iMac with Core i7 running macOS 12.3.1 and again, the script copied the files whose Retouch column contained R.


When you select the infolder and outfolder, are you double-clicking those to choose an inner folder, or just the main folders?

May 14, 2022 12:53 PM in response to VikingOSX

I'm also running this directly from Script Editor. I just copied the test data into Numbers, selected all the cells and changed the format to text, no data has quotes. I looked for extra spaces before and after the headers and verified all data is in correct columns...no extra tabs. Exported to TVS as UTF0-8.

All the files are on the desktop -- Input Image folder does not have any imbedded folders. I click the main folder and select Choose.

I get the same error. Do the images have to be in the same order as in the TSV file?

May 14, 2022 1:07 PM in response to JB001

JB001 wrote:
I get the same error. Do the images have to be in the same order as in the TSV file?

No. As the TSV Retouch column offers the letter "R", the associated filenames will be added to the retouchList array, and then you ask Finder to match files within the Infolder to that retouchList. Order in the resulting matchList is not guaranteed nor necessary to support file duplication into the outfolder.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Apple Script with M1 Chip

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