the script below runs when I insert my compact flash drive that I use with my digital SLR. Problem is, I shoot with multiple cameras, so my .NEF files get placed in different folders depending on which camera I shoot with on my LEXAR CF card. The script below targets a specific folder, but that means it missed an entirely other folder. The question is this:
[b]
how can I copy all of my .nef files from my LEXAR card when they are in different folders, WITHOUT copying the actual folders also? [/b]
Any help would be truly appreciated. Thanks!
set trashTemp to (path to desktop as text) & "trashTemp:"
set diskName to ("LEXAR MEDIA")
set path1 to (diskName & ":DCIM:120NCD1X")
set path2 to "NEF_HD:NEF temp:"
tell application "SystemUIServer"
activate
display dialog "Start transfer process?" buttons {"Cancel", "Start Transfer"} default button 2 with icon note
end tell
tell application "Bridge" to activate
--tell application "System Events" to keystroke "h" using {command down, option down}
tell application "Finder"
activate
with timeout of 10000 seconds
duplicate every item of folder path1 to folder path2 with replacing
end timeout
end tell
--say "transfer complete"
tell application "SystemUIServer"
activate
set button_pressed to button returned of (display dialog "Transfer Complete." & return & "Files in folder \"" & path2 & "\"" buttons {"Close", "Eject Drive", "Delete Files & Eject Drive"} default button 3 with icon note)
end tell
if the button_pressed is "Eject Drive" then
tell application "Finder" to eject diskName
tell application "Bridge" to activate
tell application "SystemUIServer"
activate
display dialog "You may now remove your card" buttons {"ok"} default button 1 giving up after 3
end tell
else if the button_pressed is "Delete Files & Eject Drive" then
set path3 to POSIX path of path1
do shell script "/bin/rm -rf " & (quoted form of path3) & "/*"
tell application "Finder"
eject diskName
end tell
beep
tell application "SystemUIServer"
activate
display dialog "You may now remove your card" buttons {"ok"} default button 1 giving up after 3
end tell
tell application "Bridge" to activate
end if
thanks, that’s a big help. So I needed to change the code a little bit because it targets files that are also on the disk that shouldn’t be transfered or deleted.
My directory structure for my compact Flash card is this:
The problem I am facing now is that I think there is a delete problem with the shell script. When I run the script it deletes the entire 100ND200 folder and gives me the two following script errors:
rm:/Volumes/CF/DCIM/120NCD1X/.?: File name too long
rm:/Volumes/CF/DCIM/120NCD1X: Directory not empty
Strange eh? Any idea what could be the problem? The script has changed to the following:
set trashTemp to (path to desktop as text) & "trashTemp:"
set diskName to ("CF")
set path1 to (diskName & ":DCIM")
set path2 to "NEF_HD:NEF temp:"
tell application "SystemUIServer"
activate
display dialog "Start transfer process?" buttons {"Cancel", "Start Transfer"} default button 2 with icon note
end tell
tell application "Bridge" to activate
--tell application "System Events" to keystroke "h" using {command down, option down}
tell application "Finder"
activate
with timeout of 10000 seconds
duplicate every file of entire contents of folder path1 to folder path2 with replacing
--duplicate every item of folder path1 to folder path2 with replacing
end timeout
end tell
--say "transfer complete"
tell application "SystemUIServer"
activate
set button_pressed to button returned of (display dialog "Transfer Complete." & return & "Files in folder \"" & path2 & "\"" buttons {"Close", "Eject Drive", "Delete Files & Eject Drive"} default button 3 with icon note)
end tell
if the button_pressed is "Eject Drive" then
tell application "Finder" to eject diskName
tell application "Bridge" to activate
tell application "SystemUIServer"
activate
display dialog "You may now remove your card" buttons {"ok"} default button 1 giving up after 3
end tell
else if the button_pressed is "Delete Files & Eject Drive" then
set path3 to POSIX path of path1
do shell script "/bin/rm -rf " & (quoted form of path3) & "/*"
tell application "Finder"
eject diskName
end tell
beep
tell application "SystemUIServer"
activate
display dialog "You may now remove your card" buttons {"ok"} default button 1 giving up after 3
end tell
tell application "Bridge" to activate
end if
I’m not sure, your shell syntax works on my machine
but I would prefer
set diskName to "CF"
set path1 to (diskName & ":DCIM:") -- with colon at the end
-- ...
set path3 to POSIX path of path1
-- ...
do shell script "/bin/rm -rf " & (quoted form of path3) & "*" -- without slash before the asterik
Strange, I am getting the exact same error message with those changes. File name too long? It deletes on of the folders but leaves the D1X one up with an error? Very strange.
Okay, I tried a bunch of trouble shooting and it turns out there was something wrong with that folder. Have no idea what is was, but as soon as I deleted it and placed other folders with the exact same name the issue went away.
I really appreciated your help. Thanks. If I might as one last question. Is there a command that checks for the last volume loaded? This way, instead of naming all of my CF cards the same name and hardcoading it in the script, it could just check for the last volume loaded which would always be the card since the script only runs when I attach a CF card. Is that possible?