rename files problem

I’m trying to rename files with the following but getting:

Error: Impossible to resolve «class atfn» of “Inf 1.0:Users:lsimoneau:Desktop:Transfert PDF:pdf_recus:R_01_21avr22-54.pdf” to problem “Inf 1.0:Users:lsimoneau:Desktop:Transfert PDF:pdf_recus:LDR001210406.pdf”.

on renommer()
	set the these_items to list folder target_folder without invisibles
	set target_folder to target_folder as string
	set nombreFichier to number of items in these_items as string
	log_data(nombreFichier & " fichiers à renommer." & return) of me
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set nomFichier to this_item as string
		set oldDelimiter to text item delimiters
		set text item delimiters to " "
		set destination_file_1 to text items of this_item
		set nbre_item to (count text items of destination_file_1)
		set text item delimiters to oldDelimiter
		set destination_file_2 to text items 1 thru nbre_item of destination_file_1 as string
		set nbre_car to number of characters of destination_file_2
		set nouveau to "LD" & character 1 of destination_file_2 & "0" & character 3 of destination_file_2 & character 4 of destination_file_2 & jourNum & moisNum & anneeNum & ".pdf"
		set this_item to (target_folder & this_item)
		set nouveau to (target_folder & nouveau)
		set file name of this_item to nouveau
	end repeat
end renommer

The error is caused by that line. Try replacing that line with this:

tell application "Finder"
	set name of this_item to nouveau
end tell

Getting the follwoing:

Erreur: Impossible de régler name of “Inf 1.0:Users:lsimoneau:Desktop:Transfert PDF:pdf_recus:R_01_21avr22-54.pdf” à “Inf 1.0:Users:lsimoneau:Desktop:Transfert PDF:pdf_recus:LDR001210406.pdf”.

Thank you Jacques. It is working perfectly. :slight_smile: