Get folder names of one volume - copy to the corresponding fldr ..

Hi All,

Looking for some assistance in processing folders in a list, the syntax for copying the folders is not correct, suspect this is an alias addressing issue.

Objective.
A script to copy job folder from one volume to the corresponding job folder on another volume.

Methodology.

  1. Create a list of all the job folders on the local volume.
  2. As jobs have a preflx number list only the job number not the full title.
    (In my case 5 digits)
  3. Process job folders on remote volume to check if the job exists on the local volume by querying folder name against local list.
  4. If the job (folder name) is in the list of local jobs, copy the remote folder to the corresponding folder on the local volume

NB. The job folders on the remote volume are referenced only by the 5 digit prefix, hence the shortening of names in the inital list.

Example.
If the local volume contains job folders:
10001 aphla
10002 bravo
10003 charlie
10004 delta

and the remote volume contains archive job folders:
10002
10003

Then

10002 from the remote (archive) volume would be copied into 10002 bravo (on local disk)
&
10003 from the remote (archive) volume would be copied into 10003 charlie folder (on local disk)

Script so far:

-- Select volume of local jobs
set TrgtVol to (choose folder with prompt "Where are the job folders?")

-- Select Archive volume of files
set ArchVol to (choose folder with prompt "Where are the archive folders?")


tell application "Finder"
	
	-- Shorten the name of the job folders to match the archive folder name for referencing
	set fldrlist to ""
	set jobfldrs to every folder of folder TrgtVol
	repeat with jf from 1 to count jobfldrs
		set jfname to (the name of item jf of jobfldrs as string)
		set filelength to the number of characters of jfname
		-- display dialog filelength as string
		set TrimChar to (filelength - 6)
		set jfname to (characters 1 thru -(the TrimChar + 1) of the jfname) as string
		-- display dialog TrimChar as string
		-- display dialog jfname
		set fldrlist to fldrlist & (jfname as string)
	end repeat
	display dialog fldrlist
	
	set ArchFldrs to every folder of ArchVol
	
	repeat with af from 1 to count of ArchFldrs
		set afname to (the name of item af of ArchFldrs as string)
		
		if fldrlist contains (afname as string) then
			copy folder afname of ArchVol to (folder whose name starts with (afname as string))
			-- on disk "Working"
		end if
		
	end repeat
end tell

I’ve got the inital (local) list working and the comparison to the remote volume working, just struggling with

if fldrlist contains (afname as string) then
			copy folder afname of ArchVol to (folder whose name starts with (afname as string))
			-- on disk "Working"
		end if

Any assistance greatly appreciated.

Matt.

Hi,

this is a common misunderstanding:
copy copies only a value into a variable.
To copy files with the Finder the proper commands are move or, for a real copy, duplicate