Hi everybody, I’ve started a couple of days ago to make my application.
This app moves mp3 files of a defined size to a choosen folder, and sorts them by month/year of download.
Its a simple tool for people who download lots of mp3 files and wants to keep the download folder clean as well.
What I need to do is to let the user choose an “Automatic mode” , that consist in:
-
Reading the parameters used in my app and save them to a plist file (download folder path, destination folder, sort criteria, etc);
-
Create a folder script that reads the plist file, and assign the script to user’s download folder.
Basically, there are 2 operating modes:
- manual = the user execute it when he wants to;
- automatic = the user sets everything once with the app, chooses automatic mode, and then every time a mp3 file is added to the download folder, it will be processed by my script.
---------------------- HERE IS THE PROBLEM ---------------------------
In my generated .plist file, i can see only my paths variables, but two variables are missing! They are values coming from 2 textboxes.
here is the code from the call, to plist generation.
-- Exit button
on buttonExitClicked_(sender)
set maxSizeValue to maxSize's stringValue()
set minSizeValue to minSize's stringValue()
makenewPlist()
quit
end buttonExitClicked_
on makenewPlist()
tell application "System Events"
--init
set the parent_dictionary to make new property list item with properties {kind:record}
set the plistfile_path to "~/Desktop/example.plist"
set this_plistfile to ¬
make new property list file with properties {contents:parent_dictionary, name:plistfile_path}
--save variables to plist
--working
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"downloadsFolderPOSIX", value:downloadsFolderPOSIX}
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"destinationFolderPOSIX", value:destinationFolderPOSIX}
--not working (no results in plist)
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"minSize", value:minSizeValue}
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"maxSize", value:maxSizeValue}
end tell
end makenewPlist_
This is the output:
<?xml version="1.0" encoding="UTF-8"?> destinationFolderPOSIX /Users/Funder/Desktop/ downloadsFolderPOSIX /Users/Funder/Downloads/ [b] ??? WTF, MINSIZE & MAXSIZE ???[/b]
CURIOUS FACT: the same variables are working with no problems in another part of my script, so must be something related to plist generation(hehe i’m smart!) …
do shell script "find " & downloadsFolderPOSIX & " -iname \"*.mp3\" -size +"&(minSize's stringValue())&"M -size -"&(maxSize's stringValue())&"M -execdir mv {} " & destinationFolderPOSIX & mp3craneGlobalFolder & monthYearFolder & "/ \\;"
This is the script that will be also in the “folder action script” … that’s why i need to recall the params from an external plist file!
My english is not perfect, but i hope that everything’s clear sorry for this long post, and thanks for you help!!
Model: Macbook Pro
AppleScript: AppleScriptObjC & Xcode
Browser: Safari 537.36
Operating System: Mac OS X (10.8)