Can't make string to list
Can't make string to list
- Subject: Can't make string to list
- From: "Brandon Carpenter" <email@hidden>
- Date: Tue, 23 Jan 2001 12:08:28 -0600
In the script below, I am attempting to look into a
folder where there are other folders. In those folders
are files that I want to send to SoundJam, convert them to a
differant format and send them back to thier original folder
(with everything else). Two things are happening. I am
unable to set the source_folder_contents to a string. But the
script still finds the files and adds all the files, when I
only want to work on one folder at a time. The second thing
is the script add the first file found twice.
Any feedback would be appreciated.
property source_folder : ""
property TimeToSleep : 15
on run
set source_folder to choose folder with prompt
"Please select the folder to watch:"
idle of me
end run
on idle
try
set source_folder_contents to (list folder
source_folder without invisibles)
set the_files to {}
--display dialog source_folder_contents
repeat with folder_name in source_folder_contents
try
set a_folder to alias ((source_folder as string) &
(folder_name as string))
--display dialog a_folder
set theInfo to info for a_folder
--display dialog a_folder
if (folder of theInfo is true) then
set target_file_path to (a_folder as string)
--display dialog target_file_path
--display dialog theInfo
set this_folder_contents to (list folder a_folder
without invisibles)
--display dialog this_folder_contents
set the_wavs to {}
if this_folder_contents does not contain
"audio_done.txt" then
-- look for a file with ".int" extention to
see
if we are ready to process this folder
set ready_to_process to false
repeat with this_file_name in
this_folder_contents
if this_file_name ends with ".int" then
--if this_file_name contains
"done.txt" then
set ready_to_process to true
--end if
end if
end repeat
if ready_to_process then
-- build the list of files to process
repeat with this_file_name in
this_folder_contents
-- we only want "c.wav" files
if this_file_name ends with
"c.wav" then
try
set a_file to alias
((a_folder as string) &
(this_file_name as string))
--display dialog a_file
on error
beep
end try
set the_wavs to the_wavs &
a_file
--display dialog the_wavs
tell application "SoundJam?
MP"
activate
add the_wavs
end tell
end if
end repeat
-- create the file to signal that this
folder
has been processed
try
set the target_file_path to
(a_folder as
string) & "audio_done.txt"
set the open_target_file to open
for access
the file target_file_path with write permission
write "Done encoding Audio clips."
to the
open_target_file starting at eof
close access the open_target_file
on error
try
close access the
open_target_file
end try
end try
end if
end if
end if
on error
beep 2
end try
end repeat
on error the error_message
-- enable the following line for debugging purposes
only
set total_error_msg to "ProcessFolder!" & return &
return & error_message
beep
display dialog the total_error_msg buttons {"OK"}
default button 1
end try
return TimeToSleep
end idle