Changing File Modification Date

I have a simple script that duplicates all the files in one folder into another one.

tell application "Finder"
	set sfolder to folder "path-to-folder1"
	set tfolder to folder "path-to-folder2"
	duplicate files of sfolder to tfolder with replacing
end tell

What I would like for it to do is also change the date modified on the duplicated files in the second folder. Is this doable?

Thanks,
Charlie

Model: MacBook Pro
AppleScript: 2.11
Browser: Safari 605.1.15
Operating System: macOS 10.14

I assume the modification date you want to use is the current date. I also assume that the destination folder contains other files whose modification dates should not be changed. I’ve used actual folders below so that I could insure the script works.

set sfolder to "Macintosh HD:Users:bob:Working:"
set tfolder to "Macintosh HD:Users:bob:Documents:"

tell application "Finder"
	set sfiles to every file in folder sfolder
	repeat with aFile in sfiles
		set aFileName to name of aFile
		duplicate aFile to folder tfolder with replacing
		set modification date of file (tfolder & aFileName) to (current date)
	end repeat
end tell

That works perfectly. Thank you!

No need for a loop.

set p2d to path to desktop as text
set newModDate to (current date) -- or what you want

tell application "Finder"
	set sfolder to (p2d & "Source") as alias
	set tfolder to (p2d & "Dest") as alias
	duplicate files of sfolder to tfolder with replacing
	
	set modification date of every file of tfolder to newModDate
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 23 février 2019 12:05:33

My script was based on two stated assumptions, one of which was:

“I also assume that the destination folder contains other files whose modification dates should not be changed.”

That’s why I used a repeat loop and wrote the script as I did. If the OP wants to change the modification date of every file in the destination folder, then Yvan’s script is certainly the better suggestion.