Hi, im trying to write a simple script to ask me how many copies of a file i want, and then to rename them with a file name and sequential suffix. any help would be greatly appreciated!
Hi Matt,
this should give you a start:
set thefile to choose file with prompt "Please choose a file to duplicate"
set copy_count to text returned of (display dialog "How many copies do you require?" default answer "")
set suffix_count to 2
tell application "Finder"
set file_record to {filename:name of thefile, file_ext:name extension of thefile, the_container:container of thefile}
repeat copy_count times
do shell script "cp " & quoted form of POSIX path of thefile & space & quoted form of POSIX path of ((the_container of file_record as string) & text 1 thru -((count of file_ext of file_record) + 2) of filename of file_record & "_" & suffix_count & "." & file_ext of file_record)
set suffix_count to suffix_count + 1
end repeat
end tell
Thanks,
Nik