Help with script to copy several thousand jps images to a folder

These issues are actually related. It is not a problem to just get the files, and skip over the folders, which could become part of the verification process anyway. Adam has offered some good insight on the problem, so I think we can come up with a beta pretty soon.

Let me see if I understand:

Startup, input game information, say “CougarsHuskies”
The script adds the date, so now the variable folder_root_name is “CougarsHuskies-07/30/07”
You should then see 3 folders created on your desktop entitled “CougarsHuskies-07/30/07-Quarterfinals”,“CougarsHuskies-07/30/07-Semifinals”, and “CougarsHuskies-07/30/07-Finals”. Is that not happening? Those three folders are inside of the first CF folder (“CougarsHuskies-07/30/07-1”)???

Craig

Glad the verification process is taking hold

Can “CougarsHuskies-07/30/07” be the root folder of all subfolders

CougarsHuskies-07/30/07-Quarterfinals
CougarsHuskies-07/30/07-Semifinals
CougarsHuskies-07/30/07-Finals
CougarsHuskies-07/30/07-1
thru
CougarsHuskies-07/30/07-n


As it is

CougarsHuskies-07/30/07-1 has subfolders
CougarsHuskies-07/30/07-Semifinal
CougarsHuskies-07/30/07-Finals

and

CougarsHuskies-07/30/07 has subfolder
CougarsHuskies-07/30/07-Quarterfinals

Jay

Sure, Jay, that should be simple to do; thank you for the clarification. Look for a new version when you get up tomorrow (depending on your bedtime tonight, I suppose.)

You might find this interesting. I just finished a procedure with a cat that had an “hand” abscess in conjunction with a fracture of the 4th metacarpophalangeal joint (left manus). Right up your alley!! (Awful pun intended.)

Jay:

Here are two scripts. The first one works very well in my tests. It creates the master folder on the Desktop, and all the other folders are created inside of it. It still copies the entire format of the CF card (directories included) to the proper folders:

global folder_root_name --For you, this would be the name of the game you are shooting, to which the app will attach the date
global CF_count --This will count the cards as you go, so that you don't have to worry about it
global Pict_path --Will be path to primary folder on Desktop; all other folders will be written here
global CF_transfer --Will switch from false to true depending on whether disk is being copied

on run --This is what happens when you first start the application
	set CF_transfer to false --No copying going on
	set CF_count to 1 --Card counter set to 1
	set folder_root_name to (text returned of (display dialog "Please enter name of Primary Desktop folder:" default answer "") & "-" & (my WriteDate(current date))) --You enter the name of the game, but DO NOT enter the date, the WriteDate handler will do it for you.
	my MakeBaseFolders(folder_root_name) --The main folder on the Desktop is created, and the extra folders are placed therein
end run

on idle --This loop fires every 3 seconds
	if (list disks) contains "EOS_DIGITAL" and CF_transfer = false then --If the CF card is in the list of disks, and CF_transfer state is false, we get sent to the DownLoadImages handler
		my DownLoadImages()
	end if
	return 3
end idle

on DownLoadImages()
	set CF_transfer to true --Switch the state to true, so that nobody will bother us whilst the download is happening
	tell application "Finder"
		set CF_folder to make new folder at Pict_path with properties {name:(folder_root_name & "-" & CF_count)} --make the folder to hold the card images
		duplicate entire contents of disk "EOS_DIGITAL" to CF_folder --Copy all the CF card contents to the new folder
		eject disk "EOS_DIGITAL" --eject the CF card
	end tell
	set CF_count to CF_count + 1 --Set the counter up 1
	set CF_transfer to false --reset the transfer state to false in preparation for the  next CF card
end DownLoadImages

to WriteDate(dt) --Creates a date string to tag onto the root folder name
	return (dt's month as number) & "/" & dt's day & "/" & (characters 3 thru 4 of (dt's year as string))
end WriteDate

on MakeBaseFolders(rtnm)
	set extra_Folders to {"Quarterfinals", "Semifinals", "Finals"}
	tell application "Finder"
		set Pict_path to make new folder at desktop with properties {name:rtnm} --This is now the main folder to hold all the card folders as well
		repeat with an_folder in extra_Folders
			make new folder at Pict_path with properties {name:(rtnm & "-" & (contents of an_folder))} --make the extra folders
		end repeat
	end tell
end MakeBaseFolders

This second one does the same, except that it copies a single image at a time, and upon verification of the new file’s data equalling the original file, deletes the original from the card. I cannot test it out for you, so give it a go and let me know what happens. It should NOT copy the entire folder structure of the CF card, but rather a single image at a time. If it does (by some miracle) work as advertised, I would be extremely curious to know how long it took to process x number of images.

global folder_root_name --For you, this would be the name of the game you are shooting, to which the app will attach the date
global CF_count --This will count the cards as you go, so that you don't have to worry about it
global Pict_path --Will be path to primary folder on Desktop; all other folders will be written here
global CF_transfer --Will switch from false to true depending on whether disk is being copied

on run --This is what happens when you first start the application
	set CF_transfer to false --No copying going on
	set CF_count to 1 --Card counter set to 1
	set folder_root_name to (text returned of (display dialog "Please enter name of Primary Desktop folder:" default answer "") & "-" & (my WriteDate(current date))) --You enter the name of the game, but DO NOT enter the date, the WriteDate handler will do it for you.
	my MakeBaseFolders(folder_root_name) --The main folder on the Desktop is created, and the extra folders are placed therein
end run

on idle --This loop fires every 3 seconds
	if (list disks) contains "EOS_DIGITAL" and CF_transfer = false then --If the CF card is in the list of disks, and CF_transfer state is false, we get sent to the DownLoadImages handler
		my DownLoadImages()
	end if
	return 3
end idle

on DownLoadImages()
	set CF_transfer to true --Switch the state to true, so that nobody will bother us whilst the download is happening
	tell application "Finder"
		set CF_folder to make new folder at Pict_path with properties {name:(folder_root_name & "-" & CF_count)} --make the folder to hold the card images
		set all_imgs to every file of entire contents of disk "EOS_DIGITAL"
		repeat with animg in all_imgs
			set n_img to duplicate animg to CF_folder
			my TryVerify((POSIX path of (animg as alias)), (POSIX path of (n_img as alias)))
		end repeat
		eject disk "EOS_DIGITAL" --eject the CF card
	end tell
	set CF_count to CF_count + 1 --Set the counter up 1
	set CF_transfer to false --reset the transfer state to false in preparation for the  next CF card
end DownLoadImages

to WriteDate(dt) --Creates a date string to tag onto the root folder name
	return (dt's month as number) & "/" & dt's day & "/" & (characters 3 thru 4 of (dt's year as string))
end WriteDate

on MakeBaseFolders(rtnm)
	set extra_Folders to {"Quarterfinals", "Semifinals", "Finals"}
	tell application "Finder"
		set Pict_path to make new folder at desktop with properties {name:rtnm} --This is now the main folder to hold all the card folders as well
		repeat with an_folder in extra_Folders
			make new folder at Pict_path with properties {name:(rtnm & "-" & (contents of an_folder))} --make the extra folders
		end repeat
	end tell
end MakeBaseFolders

to TryVerify(orig_file, new_file) --Concept courtesy Adam Bell
	set orig_CS to last word of (do shell script "md5 " & (quoted form of orig_file))
	set new_CS to last word of (do shell script "md5 " & (quoted form of new_file))
	if orig_CS = new_CS then do shell script ("rm -f " & (quoted form of orig_file)) --So long as the numbers agree, the original file should be summarily dismissed..
end TryVerify

Good luck,

Craig

Just tested both scripts and they work just great !

I transferred 88 files containing 1.07 GB of data
Rough times are 3 minutes for the first script and 4 minutes for the second

Those scripts are awsome

Thanks
Jay

PS Curious re manus infection with metacarpal fx
Very rare to have infected metacarpal fx in humans unless open injury

Best

Jay:

Thanks for the update. If you decide you would like to incorporate the first little script (sorting all the JPEGs from the raws), let me know, or have at it yourself, and anyone here would be happy to help with that, if you are having difficulty.

Yeah, I imagine. Cats have a lot of open injuries…

Have a great day,