Duplicating files and folders of a specified volume created time x-y

Thanks in advance for your help!

I would like to know what would be the applescript syntax for duplicating files and folders of folder RecordedVideo of Volume Gandalf created on date z between time x-y to folder RecordedVideo of Volume Sauron.

Regards!
Daniel

Hi,

try this


set dateString to "1/9/2010"
set baseDate to date dateString
set startDate to baseDate + 8 * hours
set endDate to baseDate + 15 * hours
tell application "Finder"
	duplicate (items of folder "Gandalf:RecordedVideo:" whose creation date > startDate and creation date < endDate) to folder "Sauron:RecordedVideo:"
end tell


Thanks Stefank,

Unfortunately, I am away from my desk and will not be able to test it before the next two days. However, I still have access to the web.

Since the two disk I am using are external do you beleive I should have in the syntax the word “Disk”

  duplicate (items of folder "RecordedVideo:" whose creation date > startDate and creation date < endDate) of disk "Gandalf" to folder "RecordedVideo:" of disk "Sauron"

Many thanks!
Daniel

No, the result of the two forms

folder "diskName:path:to:folder:"

and

folder "folder" of folder "to" of folder "path" of disk "diskName"

is exactly the same

Great StefanK,

What I have to remember in my syntax in the future is folder “diskName:path:to:folder:” . Is it then only a question of preferences for people to use one syntax or another? I will relook at some of the scripts I’ve created and see what I should have done not to use the work “disk”.

Sauron, is a file server connected through an ethernet cable. It always takes a while to get recognized by the system (only at the beginning). Once it’s there, there are no problems it is quickly and simply accessible, it shows like iDisk on the monitor.

I will only execute the script when the Icon of Sauron appears on the monitor. Is there something other than that I should do because this being a file server or this is just then another disk?

Daniel

Technically the Finder doesn’t distinguish a CD/DVD, hard disk, file server or flash drive.
All devices which are mounted in /Volumes are disks.

The literal string path is very versatile. You can specify a Finder specifier (folder/file/item “disk:Path:”)
or an alias (alias “disk:Path:”) or a POSIX path (POSIX path of “disk:Path:”). It’s important, that a HFS path starts always with a disk name

Thanks Stefan.

It works PERFECTLY!

Regards!
Daniel

This time I am using a TIME CAPSULE as a Storage Area Network (SAN) called FARAMIR. Under which I have the following directory structure :

Disk name - TIME CAPSULE NAME (as displayed by Airport Utility) : FARAMIR
Path : /Data/FPAQ/MPEGfiles

I’ve tried both of the following syntaxes :

set MPGDestinationFolder to "Data:FPAQ:MPEGfiles:"
set POSIXMPGFolder to POSIX path of MPGDestinationFolder
display dialog "POSIXMPGFolder: " & POSIXMPGFolder
display dialog "MPGDestinationFolder: " & MPGDestinationFolder

tell application "Finder"
	set theCardFiles to files in folder MPGDestinationFolder of disk "FARAMIR" whose name extension is "mpg"
end tell
set sortedMPGFiles to paragraphs of (do shell script "ls -U " & (quoted form of (POSIX path of (MPGDestinationFolder))))
if (count of sortedMPGFiles) is equal to 0 then
	display dialog "No MPEG-2 files found in " & MPGDestinationFolder & " folder"
	return
end if

and I am getting this AppleScript Error "Finder got an error: Can’t get disk “FARAMIR”.

set MPGDestinationFolder to "FARAMIR:Data:FPAQ:MPEGfiles:"
set POSIXMPGFolder to POSIX path of MPGDestinationFolder
display dialog "POSIXMPGFolder: " & POSIXMPGFolder
display dialog "MPGDestinationFolder: " & MPGDestinationFolder

tell application "Finder"
	set theCardFiles to files in folder MPGDestinationFolder whose name extension is "mpg"
end tell
set sortedMPGFiles to paragraphs of (do shell script "ls -U " & (quoted form of (POSIX path of (MPGDestinationFolder))))
if (count of sortedMPGFiles) is equal to 0 then
	display dialog "No MPEG-2 files found in " & MPGDestinationFolder & " folder"
	return
end if

and I am getting this AppleScript Error "Finder got an error: Can’t get folder “FARAMIR:Data:FPAQ:MPEGfiles:”.

Does it make a difference since the disk is connected through an Ethernet port and not through a Firewire/USB… ? When I look in the Finder Window FARAMIR is displayed under SHARED and not under DEVICES, does that make a difference?

Thanks again!
Daniel

Hi Daniel,

the second syntax is actually the right one, because the POSIX path coercion works only with full (HFS) paths.
Is FARAMIR the name of the parent TimeCapsule or the volume?

Drag your destination folder in an open Terminal window and you will see the full POSIX path.
The second path component (after /Volumes) is the proper name of the disk

Hello Stefan,

This is the result that I’ve got /Volumes/Data/FPAQ/MPEGfiles

FARAMIR is not even being displayed, which mean the disk is then call Data.

I’ve tried and everything is working, GREAT!

I’ve never named this disk Data, this is the name that was automatically assigned as when I’ve installed Time Capsule. I really wonder if the disk name would be the same if I had another Time Capsule. ???

I’ve tried renaming the disk and I have not been successful. I supposed I may have to use “Disk Utility” and then reformat the disk. If this the case I will not do that, I’ve got too much data already loaded.

Best regards!
Daniel