hey guys,
Little HELP:( As you can tell I’m trying to cobble this together from a bunch of different sources…Cant get the file to copy from the container folder to the C1settings folder
on open theFiles
set the DestinationFolder to path to desktop
set Bad_Extensions to {"CR2", "Tiff", "Tif", "TIF"}
repeat with ThisFile in theFiles
tell application "Finder"
set {Filename, File_Ext} to {(name of (info for ThisFile)), (name extension of (info for ThisFile))}
if Bad_Extensions contains File_Ext then
set Filename to (characters 1 thru ((offset of "." in Filename) - 1) of Filename) as string
end if
set FoldersName to (Filename) as string
make new folder at DestinationFolder with properties {name:FoldersName}
copy ThisFile to folder (DestinationFolder & FoldersName as string)
set C1 to make new folder at (DestinationFolder & FoldersName as string) with properties {name:"CaptureOne"}
set C1settings to make new folder at C1 with properties {name:"Settings45"}
set theRoot to quoted form of POSIX path of container of theFiles & "CaptureOne:settings45:" & Filename & ".cos"
do shell script "cp " & theRoot & space & C1settings --this is the problem
end tell
end repeat
end open
Hi,
there are several problems.
The keyword copy does not copy files, it copies values into variables.
The proper command of the Finder is move or duplicate.
If you’re dealing with the Finder anyway, why not using the Finder to move the file.
shell scripts work always with POSIX paths (slash separated).
A Finder file specifier like your variable C1settings must be coerced to string or alias
before it could be coerced to POSIX path
Here is a slightly optimized version
property Bad_Extensions : {"CR2", "Tiff", "Tif", "TIF"}
on open theFiles
repeat with ThisFile in theFiles
set {name:Filename, name extension:Ex} to info for ThisFile
if Bad_Extensions contains Ex then
set Filename to text 1 thru ((get offset of "." & Ex in Filename) - 1) of Filename
end if
set fileNameFolder to ((path to desktop as text) & Filename)
tell application "Finder"
set theContainer to (container of theFile) as text
if not (exists folder Filename) then
make new folder with properties {name:Filename}
end if
move ThisFile to folder fileNameFolder
set C1 to make new folder at folder fileNameFolder with properties {name:"CaptureOne"}
set C1settings to make new folder at C1 with properties {name:"Settings45"}
set theRoot to theContainer & "CaptureOne:settings45:" & Filename & ".cos"
move file theRoot to C1settings
end tell
end repeat
end open
Looks very cool. you missed an s on on of the “theFiles” This new version gives me this error Cant make <> of {alias "…} into type Unicode text. I’m trying to move a file called img_001.CR2.cos to the newfolder
sorry, it’s
set theContainer to (container of ThisFile) as text
thank you thank you thank you
property Bad_Extensions : {"CR2", "Tiff", "Tif", "TIF"}
on open theFiles
repeat with ThisFile in theFiles
set {name:Filename, name extension:Ex} to info for ThisFile
if Bad_Extensions contains Ex then
set Filename to text 1 thru ((get offset of "." & Ex in Filename) - 1) of Filename
end if
set fileNameFolder to ((path to desktop as text) & Filename)
tell application "Finder"
set theContainer to (container of ThisFile) as text
if not (exists folder Filename) then
make new folder with properties {name:Filename}
end if
duplicate ThisFile to folder fileNameFolder
set C1 to make new folder at folder fileNameFolder with properties {name:"CaptureOne"}
set C1settings to make new folder at C1 with properties {name:"Settings45"}
set theRoot to theContainer & "CaptureOne:settings45:" & Filename & "." & Ex & ".cos"
duplicate file theRoot to C1settings
end tell
end repeat
end open
Now to zip the folder and upload
Again thanks for a great site.