Author Topic: Cant move file  (Read 2067 times)

0 Members and 1 Guest are viewing this topic.

Offline Mario Ruggiero

  • Visitor
  • Posts: 2
  • Karma: 0
Cant move file
« on: December 14, 2007, 08:12:24 AM »
I'm a newbie here so be gentle with me  :)
I've written a small folder action applescript which should do the following:
get files and open them in Acrobat
print files
move files to another folder (so that I can see that they've been processed)
Trouble is I can't get the script to move files, it fails with an "NSArgumentsWrongScriptError". I think the problem is with how I defined the variable "donefolder" but I can't see where I went wrong. I hoping that someone give me some advice on this. The script is :


-- this line is for testing only remove when using as folder action
set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
set donefolder to "Printed"
set DesktopPath to path to desktop as text
set donefolder to DesktopPath & donefolder as alias


tell application "System Events"
   set these_files to every file of folder this_folder whose name extension is "pdf"
end tell
repeat with i from 1 to the count of these_files
   set this_file to (item i of these_files as alias)
   set this_info to info for this_file
   if visible of this_info is true and alias of this_info is false then
      -- insert actions here for: this_file
      tell application "Adobe Acrobat 7.0 Professional"
         activate
         open this_file
         print pages front document PS Level 2 with binary output and shrink to fit
         close front document
      end tell
   end if
   move this_file to donefolder
   --set result to this_file
   --get result
end repeat


Many thanks in advance

Offline Erik Youngren

  • Jr. Member
  • **
  • Posts: 52
  • Karma: 1
  • Gender: Male
  • Robotech and Rolemaster freak.
    • Wandering Monk Rolemaster Forums
Re: Cant move file
« Reply #1 on: December 14, 2007, 11:15:37 AM »
You've set donefolder twice. I'm not technical on these issues myself, but I have done a fair amount of poking around for moving files and such.

Try this:
-- this line is for testing only remove when using as folder action
set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
set donefolder to "Printed"
set DesktopPath to path to desktop as text
set mydonefolder to DesktopPath & donefolder as alias

rest of your script here

when you get to the move part, try this

move this_file to mydonefolder

Hope that helps.

Erik Youngren
Wandering Monk Rolemaster Forums
17" Powerbook G4 1.67Ghz • 2GB RAM •OSX 10.4.11 • QXP 8.5 • ID CS4 • Suitcase Fusion 2

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Re: Cant move file
« Reply #2 on: December 17, 2007, 03:35:00 AM »
Tell "Finder" to move your files to location.

001   property donefolder : (path to desktop as Unicode text) & "Printed" as alias
002   -- this line is for testing only remove when using as folder action
003   set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
004   
005   tell application "Finder"
006        set these_files to every file of folder this_folder whose name extension is "pdf"
007   end tell
008   
009   repeat with i from 1 to the count of these_files
010        set this_file to (item i of these_files as alias)
011        set this_info to info for this_file
012        if visible of this_info is true and alias of this_info is false then
013             -- insert actions here for: this_file
014             tell application "Adobe Acrobat 7.0 Professional"
015                  activate
016                  open this_file
017                  print pages front document PS Level 2 with binary output and shrink to fit
018                  close front document
019             end tell
020        end if
021        tell application "Finder"
022             move this_file to donefolder
023        end tell
024   end repeat

Offline Mario Ruggiero

  • Visitor
  • Posts: 2
  • Karma: 0
Re: Cant move file
« Reply #3 on: December 17, 2007, 10:26:05 AM »
Thanks for your help Eric, I tried your solution but it didn't work and I couldn't see why, so I tried larsen67's instead which did work.
Thanks very much to the both of you for your help

Offline Erik Youngren

  • Jr. Member
  • **
  • Posts: 52
  • Karma: 1
  • Gender: Male
  • Robotech and Rolemaster freak.
    • Wandering Monk Rolemaster Forums
Re: Cant move file
« Reply #4 on: December 17, 2007, 01:49:27 PM »
Mark's script will work. He knows way more than I do about this.

Erik Youngren
Wandering Monk Rolemaster Forums
17" Powerbook G4 1.67Ghz • 2GB RAM •OSX 10.4.11 • QXP 8.5 • ID CS4 • Suitcase Fusion 2

Offline Rabbit

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
  • Gender: Male
Re: Cant move file
« Reply #5 on: December 17, 2007, 05:49:06 PM »
You say that your goal is to know they have been processed.  Using finders 'Labels' and smart folder and than saving the document before or with closing. that way you don't have to do a lot of file moving.

I just read what I'd wrote, man I must have been drunk... and I don't drink.

What I saying is that when you save a file from an app it generates a new file, losing the 'label'.  so if you set the 'label' to blue than run it through your script with the last line being... here look at what I do

global P_Sty
set P_Sty to (load script alias "Macintosh HD:Users:Echo:Documents:Teaching:Scripts:My Scripts:Completed Scripts:Script Libs:Print styles Lib.scpt")
run script alias "Macintosh HD:Users:Echo:Documents:Teaching:Scripts:My Scripts:Finder:Comments auto setup - all.scpt"
tell application "Finder"
   set these_items to the selection
end tell
repeat with i from 1 to the count of these_items
   set this_item to (item i of these_items) as alias
   set Fil to this_item as text
   try
      my Pr_Fil(Fil)
      error
      my Pr_Fil(Fil)
   end try
end repeat

on Pr_Fil(Fil)
   if Fil contains ".qxd" then
      tell application "QuarkXPress 6.5"
         activate
         open alias Fil do auto picture import yes
         set bounds of front document to {0, -1680, 1050, 0}
         delay 1
         tell front document
            set Fil to name
            set num to the number of items in Fil
            set Fil to items 1 thru (num - 4) of Fil as text
            set PS_Fil to "Macintosh HD:Data File:PDFs:PS Print:" & Fil & ".ps"
            set a to the count of pages
            if a = 1 then
               tell P_Sty
                  D_Print()
               end tell
            else
               tell P_Sty
                  Sp_Print()
               end tell
            end if
            print PostScript file PS_Fil
            delay 1
         end tell
         delay 2
         close front document saving yes
      end tell
   end if
end Pr_Fil

hope this helps!
« Last Edit: December 19, 2007, 08:32:23 AM by Rabbit »
Stephen Oakes
Senior Graphic Designer
Oakes Oasis