This is perplexing, so I thought I ask the knowledable people
in here. The script below gives an error when I try combining files
in certain folders, but works fine when operating on others.
The exact error I get is this
---
"Bad name for file. Harddisk:Users:klr:Downloads:Lydb:Great Battles Of
The Ancient World:"
-37
---
A path like
"Harddisk:Users:klr:Downloads:Lydb:Great Scientific Ideas That Changed
the World:"
produces the same error, but eg.
"Harddisk:Users:klr:Downloads:Lydb:The World of Byzantium:"
works as intended.
Does anybody have a clue as to why this is so ?
NB: the names of the files in the respective folders are perfectly
legal/normal.
=======
(*
Kombiner filer med *nix kommandoen cat
*)
display dialog "Kombiner filer
Vær opmærksom på om der findes danske bogstaver i fil- og biblioteks-
navne, da resultatet i så er fald uforud- sigeligt !" buttons
{"Cancel", "OK"} default button 2 with icon stop
try
tell application "Finder" to set the source_folder to (folder of the
front window) as string
on error
end try
set the file_list to list folder source_folder without invisibles
-- It's when executing the next line that the script sometimes
-- stops with the -37 error
set the chosen_files to choose from list file_list with prompt
"Rækkefølgen er således (Marker alle):" with multiple selections
allowed
if chosen_files is equal to false then return
set file_paths to {}
repeat with aFile in chosen_files
set aFile to aFile as string
set aFile_path to quoted form of POSIX path of (source_folder &
aFile) & space
set the end of file_paths to aFile_path
end repeat
set file_paths to (file_paths as string)
set the_name to the text returned of ¬
(display dialog "Hvad skal den kombinerede fil hedde?" default
answer "" buttons {"Cancel", "OK"} default button 2 with icon note)
set cmdstring to "cat " & file_paths & " > " & quoted form of POSIX
path of (source_folder & the_name)
my DO_it(cmdstring)
--do shell script cmdstring
on DO_it(cmdstring)
tell application "Terminal"
activate
if ((count of the window) = 0) or (the busy of window 1) then
tell application "System Events"
keystroke "n" using command down
delay 1 -- sometimes "cd" is lost
end tell
end if
delay 1
do script cmdstring in window 1
end tell
end DO_it
======
--
Hilsen
Mitrokhin.