Thursday, February 23, 2017

#1 2017-01-06 10:35:00 am

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Apple Script to move files no longer works in Sierra (Help)

Hi Everyone, I hope you can help me out and I hope this is the right place to ask.

We have a script that an employee wrote a few years ago and he no longer works here, nobody here knows enough about this to fix it but we send files out to users in a zip with the script and when you run the script it's supposed to move the files from the zip to the IBM Notes Data install location (our company uses Notes for everything). This script stopped working in Sierra and only creates the folder and doesn't move the files. I hope somebody can take a look at it and tell me why it no longer works in Sierra and perhaps a fix for it as there doesn't really appear to be any kind of self-extracting solution for Mac that works for us.

If this isn't even applescript, I am sorry and maybe someone can point me to somewhere where I can get help and I hope I'm posting in here correctly. I am not a native mac user.

Applescript:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>AMApplicationBuild</key>
   <string>381</string>
   <key>AMApplicationVersion</key>
   <string>2.4</string>
   <key>AMDocumentVersion</key>
   <string>2</string>
   <key>actions</key>
   <array>
       <dict>
           <key>action</key>
           <dict>
               <key>AMAccepts</key>
               <dict>
                   <key>Container</key>
                   <string>List</string>
                   <key>Optional</key>
                   <true/>
                   <key>Types</key>
                   <array>
                       <string>com.apple.applescript.object</string>
                   </array>
               </dict>
               <key>AMActionVersion</key>
               <string>1.0.2</string>
               <key>AMApplication</key>
               <array>
                   <string>Automator</string>
               </array>
               <key>AMParameterProperties</key>
               <dict>
                   <key>source</key>
                   <dict/>
               </dict>
               <key>AMProvides</key>
               <dict>
                   <key>Container</key>
                   <string>List</string>
                   <key>Types</key>
                   <array>
                       <string>com.apple.applescript.object</string>
                   </array>
               </dict>
               <key>ActionBundlePath</key>
               <string>/System/Library/Automator/Run AppleScript.action</string>
               <key>ActionName</key>
               <string>Run AppleScript</string>
               <key>ActionParameters</key>
               <dict>
                   <key>source</key>
                   <string>-- Version 1.2 Click Me Script
-- Updated Nov. 20, 2013
-- Added Notes 9 folder support

tell application "System Events"
   set userName to name of current user
end tell

tell application "Finder"
   set folderName to "folder name here" as text
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   
   set theTargetFolder to ("Macintosh HD:Users:" & userName & ":Library:Application Support:Lotus Notes Data:")
   set theCourseFolder to ("Macintosh HD:Users:" & userName & ":Library:Application Support:Lotus Notes Data:" & folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to ("Macintosh HD:Users:" & userName & ":Library:Application Support:IBM Notes Data:")
       set theCourseFolder to ("Macintosh HD:Users:" & userName & ":Library:Application Support:IBM Notes Data:" & folderName)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:folderName}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell</string>
               </dict>
               <key>BundleIdentifier</key>
               <string>com.apple.Automator.RunScript</string>
               <key>CFBundleVersion</key>
               <string>1.0.2</string>
               <key>CanShowSelectedItemsWhenRun</key>
               <false/>
               <key>CanShowWhenRun</key>
               <true/>
               <key>Category</key>
               <array>
                   <string>AMCategoryUtilities</string>
               </array>
               <key>Class Name</key>
               <string>RunScriptAction</string>
               <key>InputUUID</key>
               <string>0F225918-9142-442F-92A9-B9032A232B6F</string>
               <key>Keywords</key>
               <array>
                   <string>Run</string>
               </array>
               <key>OutputUUID</key>
               <string>F8B2933E-DE4D-4D38-88BB-49C5F86E6A27</string>
               <key>UUID</key>
               <string>6C8E865E-235B-44E0-BA48-CE29DBD45F57</string>
               <key>UnlocalizedApplications</key>
               <array>
                   <string>Automator</string>
               </array>
               <key>arguments</key>
               <dict>
                   <key>0</key>
                   <dict>
                       <key>default value</key>
                       <string>on run {input, parameters}
   
   (* Your script goes here *)
   
   return input
end run</string>
                       <key>name</key>
                       <string>source</string>
                       <key>required</key>
                       <string>0</string>
                       <key>type</key>
                       <string>0</string>
                       <key>uuid</key>
                       <string>0</string>
                   </dict>
               </dict>
               <key>conversionLabel</key>
               <integer>0</integer>
               <key>isViewVisible</key>
               <true/>
               <key>location</key>
               <string>309.500000:498.000000</string>
               <key>nibPath</key>
               <string>/System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib</string>
           </dict>
           <key>isViewVisible</key>
           <true/>
       </dict>
   </array>
   <key>connectors</key>
   <dict/>
   <key>workflowMetaData</key>
   <dict>
       <key>workflowTypeIdentifier</key>
       <string>com.apple.Automator.application</string>
   </dict>
</dict>
</plist>

Offline

 

#2 2017-01-06 11:01:06 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

I'm unable to study the Xml components.
I made a bit of cleaning to the "pure" AppleScript part which behaves flawlessly.

Applescript:

-- Added Notes 9 folder support

set pathToApplicationSupport to path to application support from user domain as text # Edited according to StefanK's message

tell application "Finder"
   set folderName to "folder name here" as text
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   
   set theTargetFolder to (pathToApplicationSupport & "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport & "Lotus Notes Data:" & folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport & "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport & "IBM Notes Data:" & folderName)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:folderName}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell

For my own use I would drop the Xml instructions, save the code given above as an application and put it in the folder containing the nfs documents.

The person which will unzip the archive (zip file) will just have to double click the embedded script-application.
For test I saved the script as double click me.app

Source Folder :
/Users/myHome/Desktop/my Container/
    double click me.app
    2017-01-06T10.57.34.nsf
    2017-01-06T11.01.03.nsf

After use :
/Users/myHome/Desktop/my Container/
    double click me.app

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    folder name here
        2017-01-06T10.57.34.nsf
        2017-01-06T11.01.03.nsf

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:00:14

Last edited by Yvan Koenig (2017-01-06 11:56:04 am)

Offline

 

#3 2017-01-06 11:05:19 am

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

I appreciate the response, but I am a completely noob and need laymens terms. What xml components are you referring to? I tried replacing the code with what you posted and now the script says its damaged when i try to run it. I honestly have no idea how this stuff works.

Here's the app in it's entirety if that helps
https://drive.google.com/file/d/0B6kpxH … sp=sharing

When I put just your code in a file and make it a .app it says this type of file is not supported on this mac when I try to run it.

Last edited by myztklkev (2017-01-06 11:28:04 am)

Offline

 

#4 2017-01-06 11:29:20 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

The Xml components are all the instructions starting with the character "<".

The process is simple.
Go back in my message
Double click the button [Open this Scriplet in your Editor:]
You will get the script in Apple's Script Editor

Menu bar:
File > Save
You will get the Save dialog
Near its bottom is a local menu which defaults with "Script"
Click on it to see the other options and select "Application"
At the top you will see a field containing untitled.app
Edit it as double click me.app
Click the Save button at the bottom- right of the dialog.

Then, using the Finder, move the double click me.app file in the folder containing the files to transfer.

I uploaded a screenshot of the Save dialog in my Box public folder.
You may get it at this link :
https://app.box.com/s/x3nwtojzbi8ehu8ms4u09ra1wykqvrpt
I apologizes but it's made from a system running in French.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:28:57

Last edited by Yvan Koenig (2017-01-06 11:56:43 am)

Offline

 

#5 2017-01-06 11:40:46 am

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

The Xml components are all the instructions starting with the character "<".

The process is simple.
Go back in my message
Double click the button [Open this Scriplet in your Editor:]
You will get the script in Apple's Script Editor

Menu bar:
File > Save
You will get the Save dialog
Near its bottom is a local menu which defaults with "Script"
Click on it to see the other options and select "Application"
At the top you will see a field containing untitled.app
Edit it as mover.app
Click the Save button at the bottom- right of the dialog.

Then, using the Finder, move the mover.app file in the folder containing the files to transfer.

I uploaded a screenshot of the Save dialog in my Box public folder.
You may get it at this link :
https://app.box.com/s/x3nwtojzbi8ehu8ms4u09ra1wykqvrpt
I apologizes but it's made from a system running in French.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:28:57

yeah I figured it out and I appreciate it, but there's a problem with this. Our old script we could just open the workflow file in notepad++ and edit the folder name and save it, with this way it doesn't seem like that's possible and I would have to re-compile the script with a different folder name every time which I don't think is feasible. Any suggestions?

Offline

 

#6 2017-01-06 11:43:48 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

Your click me.app is an application bundle containing an Automator workflow.
In your test folder, put only my script saved as an application and some nsf files.
Maybe it would be better to save the script as "double click me.app"

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:43:43

Offline

 

#7 2017-01-06 11:47:13 am

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11416
Website

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan, there is even

Applescript:

set pathToApplicationSupport to path to application support folder from user domain as text


regards

Stefan

Offline

 

#8 2017-01-06 11:48:09 am

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

Your click me.app is an application bundle containing an Automator workflow.
In your test folder, put only my script saved as an application and some nsf files.
Maybe it would be better to save the script as "double click me.app"

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:43:43

yeah I got your script to work, but we need to be able to easily change the folder name like we used to be able to. This way, I would have to re-compile the script with a different folder name every time. We use this to send IBM Notes databases to users and they folders need to be dated so files don't get overwritten.

Offline

 

#9 2017-01-06 11:50:09 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

Thanks Stefan

I missed it in the list given in Standard Additions dictionary.

At this time it seems that the problem is not the code itself but the way to use it.

May you look at my explanations and rewrite them in a better English ?

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:50:01

Offline

 

#10 2017-01-06 12:00:59 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

myztklkev wrote:

Yvan Koenig wrote:

Your click me.app is an application bundle containing an Automator workflow.
In your test folder, put only my script saved as an application and some nsf files.
Maybe it would be better to save the script as "double click me.app"

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:43:43

yeah I got your script to work, but we need to be able to easily change the folder name like we used to be able to. This way, I would have to re-compile the script with a different folder name every time. We use this to send IBM Notes databases to users and they folders need to be dated so files don't get overwritten.

Glad to read that you got it running.

I apologizes but as I wrote, I know nothing about the Xml code which I guess is the one treating the folder name.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 19:00:54

Offline

 

#11 2017-01-06 12:14:36 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

myztklkev wrote:

Yvan Koenig wrote:

Your click me.app is an application bundle containing an Automator workflow.
In your test folder, put only my script saved as an application and some nsf files.
Maybe it would be better to save the script as "double click me.app"

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 18:43:43

yeah I got your script to work, but we need to be able to easily change the folder name like we used to be able to. This way, I would have to re-compile the script with a different folder name every time. We use this to send IBM Notes databases to users and they folders need to be dated so files don't get overwritten.

Glad to read that you got it running.

I apologizes but as I wrote, I know nothing about the Xml code which I guess is the one treating the folder name.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 19:00:54

I'll make it work, I'll just have to write up some documentation for my colleagues so that they can recompile the script with whatever folder name they need. It's just a bummer we are forced to use our Mac to do this now instead of just being able to open the workflow in Notepad++ and change the folder name. None of us here are mac users, we just have one in the office to test things. I really appreciate the help, my colleague has been trying to find a solution for this for months and I literally spent 2 hours on this forum and already got something that works lol. Thanks for that. However, if anyone is keen enough to figure out how to get this to work with a workflow, by all means I'll take it.

Offline

 

#12 2017-01-06 12:15:02 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

Here is an edited version.

Applescript:

-- Added Notes 9 folder support

set pathToApplicationSupport to path to application support from user domain as text # Edited according to StefanK's message

tell application "Finder"
   --set folderName to "folder name here" as text # DISABLED
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   set folderName to name of thisFolder # ADDED
   
   set theTargetFolder to (pathToApplicationSupport & "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport & "Lotus Notes Data:" & folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport & "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport & "IBM Notes Data:" & folderName)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:folderName}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell

It defines the destination folder (folderName) according to the name of the folder in which you put the nrs files and the application itself.

Source Folder :
/Users/myHome/Desktop/my Container/
    double click me.app
    2017-01-06T10.57.34.nsf
    2017-01-06T11.01.03.nsf

After use :
/Users/myHome/Desktop/my Container/
    double click me.app

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    my Container
        2017-01-06T10.57.34.nsf
        2017-01-06T11.01.03.nsf

If you change the name of your folder the files will be moved in an other folder as described below.
Source Folder :
/Users/myHome/Desktop/Nabuchodonosor/
    double click me.app
    2017-01-04T10.57.34.nsf
    2017-01-04T11.01.03.nsf

After use :
/Users/myHome/Desktop/ Nabuchodonosor/
    double click me.app

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    Nabuchodonosor
        2017-01-04T10.57.34.nsf
        2017-01-04T11.01.03.nsf

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 19:13:44

Offline

 

#13 2017-01-06 12:22:27 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11416
Website

Re: Apple Script to move files no longer works in Sierra (Help)

@Yvan, my English is not better than yours


@myztklkev You can prompt the user to select the folder and enter a folder name

Applescript:


...
set thisFolder to choose folder with prompt "Choose source folder"
...
set folderName to text returned of (display dialog "Enter Folder name" default answer "")
...


regards

Stefan

Offline

 

#14 2017-01-06 12:34:08 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

I found a reason explaining that the workflow failed.
It uses linefeed as line break character.
Pasting the script in it inserted text using return as line break character.

Here is the document.workflow in which I inserted my script with the correct linefeeds.

Applescript:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>AMApplicationBuild</key>
   <string>381</string>
   <key>AMApplicationVersion</key>
   <string>2.4</string>
   <key>AMDocumentVersion</key>
   <string>2</string>
   <key>actions</key>
   <array>
       <dict>
           <key>action</key>
           <dict>
               <key>AMAccepts</key>
               <dict>
                   <key>Container</key>
                   <string>List</string>
                   <key>Optional</key>
                   <true/>
                   <key>Types</key>
                   <array>
                       <string>com.apple.applescript.object</string>
                   </array>
               </dict>
               <key>AMActionVersion</key>
               <string>1.0.2</string>
               <key>AMApplication</key>
               <array>
                   <string>Automator</string>
               </array>
               <key>AMParameterProperties</key>
               <dict>
                   <key>source</key>
                   <dict/>
               </dict>
               <key>AMProvides</key>
               <dict>
                   <key>Container</key>
                   <string>List</string>
                   <key>Types</key>
                   <array>
                       <string>com.apple.applescript.object</string>
                   </array>
               </dict>
               <key>ActionBundlePath</key>
               <string>/System/Library/Automator/Run AppleScript.action</string>
               <key>ActionName</key>
               <string>Run AppleScript</string>
               <key>ActionParameters</key>
               <dict>
                   <key>source</key>
                   <string>-- Version 1.2 Click Me Script
-- Updated Jan. 06, 2016
-- Added Notes 9 folder support

set pathToApplicationSupport to path to application support from user domain as text

tell application "Finder"
   set folderName to "folder name here" as text
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   --set folderName to name of thisFolder
   
   set theTargetFolder to (pathToApplicationSupport & "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport & "Lotus Notes Data:" & folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport & "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport & "IBM Notes Data:" & folderName)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:folderName}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell</string>
               </dict>
               <key>BundleIdentifier</key>
               <string>com.apple.Automator.RunScript</string>
               <key>CFBundleVersion</key>
               <string>1.0.2</string>
               <key>CanShowSelectedItemsWhenRun</key>
               <false/>
               <key>CanShowWhenRun</key>
               <true/>
               <key>Category</key>
               <array>
                   <string>AMCategoryUtilities</string>
               </array>
               <key>Class Name</key>
               <string>RunScriptAction</string>
               <key>InputUUID</key>
               <string>0F225918-9142-442F-92A9-B9032A232B6F</string>
               <key>Keywords</key>
               <array>
                   <string>Run</string>
               </array>
               <key>OutputUUID</key>
               <string>F8B2933E-DE4D-4D38-88BB-49C5F86E6A27</string>
               <key>UUID</key>
               <string>6C8E865E-235B-44E0-BA48-CE29DBD45F57</string>
               <key>UnlocalizedApplications</key>
               <array>
                   <string>Automator</string>
               </array>
               <key>arguments</key>
               <dict>
                   <key>0</key>
                   <dict>
                       <key>default value</key>
                       <string>on run {input, parameters}
   
   (* Your script goes here *)
   
   return input
end run</string>
                       <key>name</key>
                       <string>source</string>
                       <key>required</key>
                       <string>0</string>
                       <key>type</key>
                       <string>0</string>
                       <key>uuid</key>
                       <string>0</string>
                   </dict>
               </dict>
               <key>conversionLabel</key>
               <integer>0</integer>
               <key>isViewVisible</key>
               <true/>
               <key>location</key>
               <string>309.500000:498.000000</string>
               <key>nibPath</key>
               <string>/System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib</string>
           </dict>
           <key>isViewVisible</key>
           <true/>
       </dict>
   </array>
   <key>connectors</key>
   <dict/>
   <key>workflowMetaData</key>
   <dict>
       <key>workflowTypeIdentifier</key>
       <string>com.apple.Automator.application</string>
   </dict>
</dict>
</plist>

I edited the text according to what I discovered some minutes ago.
The problem was that in the block containing the real AppleScript code, the ampersand characters "&" required to be encoded as "&amp;"
I can't do the changes above because they would be automatically destroyed.
You may see below the lines in which some changes must be applied - highlighter in underlined bold.

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
set theTargetFolder to (pathToApplicationSupport &amp; "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport &amp; "Lotus Notes Data:" &amp; folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport &amp; "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport &amp; "IBM Notes Data:" &amp; folderName)
   end if
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

I used the edited app here under 10.12.2 and it moved the files to the folder
"/Users/myHome/Library/Application Support/Lotus Notes Data/folder name here/"

Of course I am unable to reproduce what you use to pass it the name of the destination folder.

Test it on your machine.
If it fails I assumes that it's the process inserting the folder name which plays the fool.

You may send a mail to : k o e n i g . y v a n @ s f r . f r
so that I may send you the Click Me .app with the edited workflow.

Just a question. There is a space between "Me" and ".app" in the app name. May it be the origin of your problem.
Maybe it was not here in the past and the scheme supposed to insert the folder name is fooled by that.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 19:27:53

Last edited by Yvan Koenig (2017-01-08 11:05:26 am)

Offline

 

#15 2017-01-06 12:58:32 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

StefanK wrote:

@Yvan, my English is not better than yours


@myztklkev You can prompt the user to select the folder and enter a folder name

Applescript:


...
set thisFolder to choose folder with prompt "Choose source folder"
...
set folderName to text returned of (display dialog "Enter Folder name" default answer "")
...

sadly we can't trust our users to do anything on their own properly. We have this script because most of our users are not competent enough to move the files manually to the IBM Notes Data folder, so getting them to pick the directory would be just as bad.

Last edited by myztklkev (2017-01-06 01:17:20 pm)

Offline

 

#16 2017-01-06 01:01:03 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

I found a reason explaining that the workflow failed.
It uses linefeed as line break character.
Pasting the script in it inserted text using return as line break character.

Here is the document.workflow in which I inserted my script with the correct linefeeds.

Here it fails but I'm not really surprised because it embed some datas which may be specific to your settings.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 19:27:53

That's all jibberish to me unfortunately. This workflow/script works in every version of Mac OS that we've tried except Sierra.

Last edited by myztklkev (2017-01-06 01:01:27 pm)

Offline

 

#17 2017-01-06 02:12:49 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

Here is an edited version.

Applescript:

-- Added Notes 9 folder support

set pathToApplicationSupport to path to application support from user domain as text # Edited according to StefanK's message

tell application "Finder"
   --set folderName to "folder name here" as text # DISABLED
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   set folderName to name of thisFolder # ADDED
   
   set theTargetFolder to (pathToApplicationSupport & "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport & "Lotus Notes Data:" & folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport & "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport & "IBM Notes Data:" & folderName)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:folderName}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell

It defines the destination folder (folderName) according to the name of the folder in which you put the nrs files and the application itself.

Source Folder :
/Users/myHome/Desktop/my Container/
    double click me.app
    2017-01-06T10.57.34.nsf
    2017-01-06T11.01.03.nsf

After use :
/Users/myHome/Desktop/my Container/
    double click me.app

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    my Container
        2017-01-06T10.57.34.nsf
        2017-01-06T11.01.03.nsf

If you change the name of your folder the files will be moved in an other folder as described below.
Source Folder :
/Users/myHome/Desktop/Nabuchodonosor/
    double click me.app
    2017-01-04T10.57.34.nsf
    2017-01-04T11.01.03.nsf

After use :
/Users/myHome/Desktop/ Nabuchodonosor/
    double click me.app

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    Nabuchodonosor
        2017-01-04T10.57.34.nsf
        2017-01-04T11.01.03.nsf

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 19:13:44

I didn't even notice you post this. I will have to take a look, and if it works good I will use it, it definitely seems like a better alternative then having to recompile the script every time. I greatly appreciate all the help.

Edit: This is fantastic! thank you

Last edited by myztklkev (2017-01-06 02:41:45 pm)

Offline

 

#18 2017-01-06 02:45:57 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

StefanK wrote:

@Yvan, my English is not better than yours


@myztklkev You can prompt the user to select the folder and enter a folder name

Applescript:


...
set thisFolder to choose folder with prompt "Choose source folder"
...
set folderName to text returned of (display dialog "Enter Folder name" default answer "")
...

In the original script, thisFolder is the folder containing the script and the files to move.
There is no need to define it thru a dialog.

The instruction:
set folderName to text returned of (display dialog "Enter Folder name" default answer "")
makes sense.

Honestly, I have some difficulties to understand the problem.
At this time I know that folderName was defined in Notepad++.
This doesn't help because every word processor would do the job.
But this tell us that the sender is able to enter the directory and more, to enter in the package named click me.app to reach the file named document.wflow.

This means that this sender is able to navigate in the hierarchy:


   SourceFolder
      Click Me.app
         Contents
            document.wflow

I have an idea which seems to be viable.
What if we store the folderName in a text file stored in the folder with the script

We would  have:

Source Folder :
/Users/myHome/Desktop/my Container/
    double click me.app
    folderNameInside.txt -- a text file containing the name to use. Mathusalem for instance
    2017-01-06T10.57.34.nsf
    2017-01-06T11.01.03.nsf

After use :
/Users/myHome/Desktop/my Container/
    double click me.app
    folderNameInside.txt -- a text file containing the name to use. Mathusalem for instance

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    Mathusalem
        2017-01-06T10.57.34.nsf
        2017-01-06T11.01.03.nsf

To do that, save the script below as an application named  "double click me.app"

Applescript:

-- Added Notes 9 folder support

set pathToApplicationSupport to path to application support from user domain as text

tell application "Finder"
   --set folderName to "folder name here" as text
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   
   # builds the path to the text file containing the filename to use
   set theTextFile to (thisFolder as text) & "folderNameInside.txt"
   # Read the text file
   tell me to set maybe to (read file theTextFile)
   # Drops the possible line breaks available in the text file
   set foldername to paragraph 1 of maybe
   
   set theTargetFolder to (pathToApplicationSupport & "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport & "Lotus Notes Data:" & foldername)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport & "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport & "IBM Notes Data:" & foldername)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:foldername}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell

For my tests, fileNameInside.txt contained :

Mathusalem

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 21:42:39

Last edited by Yvan Koenig (2017-01-06 02:52:19 pm)

Offline

 

#19 2017-01-06 03:03:01 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

StefanK wrote:

@Yvan, my English is not better than yours


@myztklkev You can prompt the user to select the folder and enter a folder name

Applescript:


...
set thisFolder to choose folder with prompt "Choose source folder"
...
set folderName to text returned of (display dialog "Enter Folder name" default answer "")
...

In the original script, thisFolder is the folder containing the script and the files to move.
There is no need to define it thru a dialog.

The instruction:
set folderName to text returned of (display dialog "Enter Folder name" default answer "")
makes sense.

Honestly, I have some difficulties to understand the problem.
At this time I know that folderName was defined in Notepad++.
This doesn't help because every word processor would do the job.
But this tell us that the sender is able to enter the directory and more, to enter in the package named click me.app to reach the file named document.wflow.

This means that this sender is able to navigate in the hierarchy:


   SourceFolder
      Click Me.app
         Contents
            document.wflow

I have an idea which seems to be viable.
What if we store the folderName in a text file stored in the folder with the script

We would  have:

Source Folder :
/Users/myHome/Desktop/my Container/
    double click me.app
    folderNameInside.txt -- a text file containing the name to use. Mathusalem for instance
    2017-01-06T10.57.34.nsf
    2017-01-06T11.01.03.nsf

After use :
/Users/myHome/Desktop/my Container/
    double click me.app
    folderNameInside.txt -- a text file containing the name to use. Mathusalem for instance

Destination folder :
/Users/myHome/Library/Application Support/Lotus Notes Data/
    Mathusalem
        2017-01-06T10.57.34.nsf
        2017-01-06T11.01.03.nsf

To do that, save the script below as an application named  "double click me.app"

Applescript:

-- Added Notes 9 folder support

set pathToApplicationSupport to path to application support from user domain as text

tell application "Finder"
   --set folderName to "folder name here" as text
   set successFlag to 0
   --set thisFolder to (target of front Finder window) as alias
   --set thisFolder to POSIX path of ((container of (path to me)) as text)
   set thisFolder to ((container of (path to me)) as alias)
   
   # builds the path to the text file containing the filename to use
   set theTextFile to (thisFolder as text) & "folderNameInside.txt"
   # Read the text file
   tell me to set maybe to (read file theTextFile)
   # Drops the possible line breaks available in the text file
   set foldername to paragraph 1 of maybe
   
   set theTargetFolder to (pathToApplicationSupport & "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport & "Lotus Notes Data:" & foldername)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport & "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport & "IBM Notes Data:" & foldername)
   end if
   
   set filesToMove to (every file of thisFolder whose name extension is "nsf")
   
   if (exists folder theCourseFolder) is false then
       make new folder at theTargetFolder with properties {name:foldername}
   end if
   
   try
       move filesToMove to theCourseFolder
   on error
       display dialog "File(s) already exist. Do you wish to overwrite?" buttons {"Yes", "No"}
       if the button returned of the result is "Yes" then
           move filesToMove to theCourseFolder with replacing
       else
           set successFlag to 1
       end if
       
   end try
   
   if successFlag = 0 then
       display dialog "File(s) moved successfully." buttons {"OK"}
   else
       display dialog "File(s) not moved." buttons {"OK"}
   end if
   
end tell

For my tests, fileNameInside.txt contained :

Mathusalem

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 21:42:39

I appreciate the further support but the script you came up with that uses the folder name that the nsf's and the clickme resides in will work perfectly for us. So we will just have to put the nsf's and the click me in the properly named folder before we send the zip to users which is just as easy/if not easier than being able to edit the folder name in the workflow file. And you are correct, any file editor will do, we just use notepad++ Thank you again for all your support, you just made our lives here much easier again.

Offline

 

#20 2017-01-08 11:37:59 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

I added comments to message #14 but I decided to post them here so that I hope that you will see them.

I edited the text according to what I discovered some minutes ago.
The problem was that in the block containing the real AppleScript code, the ampersand characters "&" required to be encoded as "&amp;"
I can't do the changes above because they would be automatically destroyed.
You may see below the lines in which some changes must be applied - highlighter in underlined bold.

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
set theTargetFolder to (pathToApplicationSupport &amp; "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport &amp; "Lotus Notes Data:" &amp; folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport &amp; "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport &amp; "IBM Notes Data:" &amp; folderName)
   end if
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

I used the edited app here under 10.12.2 and it moved the files to the folder
"/Users/myHome/Library/Application Support/Lotus Notes Data/folder name here/"

Of course I am unable to reproduce what you use to pass it the name of the destination folder.

Test it on your machine.
If it fails I assumes that it's the process inserting the folder name which plays the fool.

You may send a mail to : k o e n i g . y v a n @ s f r . f r
so that I may send you the Click Me .app with the edited workflow.

Just a question. There is a space between "Me" and ".app" in the app name. May it be the origin of your problem.
Maybe it was not here in the past and the scheme supposed to insert the folder name is fooled by that.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) dimanche 8 janvier 2017 18:37:42

Offline

 

#21 2017-01-08 02:27:36 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

Yvan Koenig wrote:

I added comments to message #14 but I decided to post them here so that I hope that you will see them.

I edited the text according to what I discovered some minutes ago.
The problem was that in the block containing the real AppleScript code, the ampersand characters "&" required to be encoded as "&amp;"
I can't do the changes above because they would be automatically destroyed.
You may see below the lines in which some changes must be applied - highlighter in underlined bold.

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
set theTargetFolder to (pathToApplicationSupport &amp; "Lotus Notes Data:")
   set theCourseFolder to (pathToApplicationSupport &amp; "Lotus Notes Data:" &amp; folderName)
   
   if (exists folder theTargetFolder) is false then
       set theTargetFolder to (pathToApplicationSupport &amp; "IBM Notes Data:")
       set theCourseFolder to (pathToApplicationSupport &amp; "IBM Notes Data:" &amp; folderName)
   end if
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

I used the edited app here under 10.12.2 and it moved the files to the folder
"/Users/myHome/Library/Application Support/Lotus Notes Data/folder name here/"

Of course I am unable to reproduce what you use to pass it the name of the destination folder.

Test it on your machine.
If it fails I assumes that it's the process inserting the folder name which plays the fool.

You may send a mail to : k o e n i g . y v a n @ s f r . f r
so that I may send you the Click Me .app with the edited workflow.

Just a question. There is a space between "Me" and ".app" in the app name. May it be the origin of your problem.
Maybe it was not here in the past and the scheme supposed to insert the folder name is fooled by that.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) dimanche 8 janvier 2017 18:37:42

It's not a big deal, we don't need to use the workflow and I'm guessing it was just set up that way originally by someone with barely more experience than me with applescript and from what I hear he got the workflow elsewhere and just inserted his script. Your pure applescript that you came up with using the starting folder name works fine for us and I tested it successfully on both our machines. Once again though I thank you for your vigilance

Browser: Firefox 50.0

Last edited by myztklkev (2017-01-08 02:28:44 pm)

Offline

 

#22 2017-01-08 02:29:20 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11416
Website

Re: Apple Script to move files no longer works in Sierra (Help)

Looking at the script I'm noticing that at a few places strings are used rather than Finder or Alias specifiers.

For example theCourseFolder is just an HFS path.
I'm not sure that it helps but it is better programming habit to write

Applescript:

move filesToMove to folder theCourseFolder


regards

Stefan

Offline

 

#23 2017-01-08 02:30:44 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11416
Website

Re: Apple Script to move files no longer works in Sierra (Help)

@myztklkev

Please do not quote always the entire message. Quote only the relevant parts.


regards

Stefan

Offline

 

#24 2017-01-09 03:50:45 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 2826

Re: Apple Script to move files no longer works in Sierra (Help)

StefanK wrote:

Looking at the script I'm noticing that at a few places strings are used rather than Finder or Alias specifiers.

For example theCourseFolder is just an HFS path.
I'm not sure that it helps but it is better programming habit to write

Applescript:

move filesToMove to folder theCourseFolder

Hello Stefan

I was surprised when I saw this instruction in the original code. As I wrote many times, I hate the Finder so I'm not accustomed to its exact behavior. I was ready to edit the instruction but curiosity was too big and I tested. As it is the instruction did its duty so I choose to leave them untouched.
This morning I re-tested :
the code using the name of the folder to move to define the name of the target one.
The same encapsulated in the workflow
the code using the name stored in a text file to define the name of the target one.
All of them behaved flawlessly.
I would be surprised if this antediluvian beast named Finder change its behavior.
I looked again in Finder's dictionary. Specifier is used several times but is never defined.
It seems that its definition is not really precise.

Move and Duplicate behave well when the target folder is defined by a string. The old beast knows that when it's asked to execute them the target is necessarily a folder and it behaves accordingly.

Yvan KOENIG running SIerra 10.12.2 in French (VALLAURIS, France) lundi 9 janvier 2017 10:50:38

Offline

 

#25 2017-01-11 01:43:25 pm

myztklkev
Member
Registered: 2017-01-05
Posts: 13

Re: Apple Script to move files no longer works in Sierra (Help)

myztklkev wrote:

I appreciate the further support but the script you came up with that uses the folder name that the nsf's and the clickme resides in will work perfectly for us. So we will just have to put the nsf's and the click me in the properly named folder before we send the zip to users which is just as easy/if not easier than being able to edit the folder name in the workflow file. And you are correct, any file editor will do, we just use notepad++ Thank you again for all your support, you just made our lives here much easier again.

So I'm running into another problem now, for some reason when we take the click me file and put it in a folder with an nsf and then zip the folder. I can email that file to a mac user and when they open it (which auto-extracts the folder) and run the click me it works, but if I put the file on a download server and the user downloads via a link the click me file will not work until you move it out of the containing folder and put it back in which make absolutely zero sense to me because the zip is the exact same file and downloading it from a link should make no difference unless web browsers handle zips differently.

EDIT: ok, So i discovered that this functions like this no matter what script we use. I tried our original script with the workflow and if you copy it out of the containing folder to say the desktop and then move it back to the containing folder, it runs and moves the files. So something the way the browser handles the zip in Sierra or something breaks something.

Last edited by myztklkev (2017-01-11 02:22:22 pm)

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.203 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)