Copy filename, process file (unzip), paste filename

Hi,

I hope I find help here as a Newbie to AppleScript. Actually I just use a script to solve a big issue of data recovery.
On my girlfriends PC a corrupted backup left thousands of files of such kind:

File names are orginal but have an extension “.nco”
After renaming from “.nco” to “.zip” the files can be unzipped on my mac and the originals are recovered.

The only problem is, that the filename than is the complete path to the original path eg “file0290302_125205_Installation\C\DOKUME~1\INSTAL~1\EIGENE~1\ADRESS~1” and because of the lenght the end of name is cut off.

So my idea for a helping script is as follows / the script should perform this:

  1. Work on the content of a folder (front window)
  2. Take first file and rename it from “.nco” to “.zip”
  3. Copy the files name excluding the extension “.zip”
  4. Open the file using the systems “Archiving” application to unzip the file
  5. Paste the original name
  6. Delete the .zip file
  7. Go on with the next file of folder

Big parts of the script are ready, eg I managed to script step 1) - 2)
Also Step 4) is no big deal.
Step 6) I solved telling the prefs of the Archiving application to delete source after unzip

For step 3) and 5) I tried several ways but I am not successful solving this issue.

Can anyone help me?!?

Thank you very much, Kai

Some facts:
The files are named like “file0290302.jpg.nco”
After unzipping the are named for example “file0290302_125205_Installation\C\DOKUME~1\INSTAL~1\EIGENE~1\ADRESS~1”
After pasting the “name before unzip” the files now are named "“file0290302.jpg”

My script looks like this right now:


try
	tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
	set the source_folder to path to desktop folder as alias
end try

-- file rename -----------------------------------

tell application "Finder"
	try
		set kFiles to every file of folder source_folder
		repeat with currFile in kFiles
			set name of contents of currFile to (text 1 thru -9 of (get name of currFile) & ".zip")
			
		end repeat
		
	end try
end tell

-- File   N E W   chose -----------------------------------

try
	tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
	set the source_folder to path to desktop folder as alias
end try

-- Name copy ??????? ----------------------------------------

tell application "Finder"
	try
		set kFiles to every file of folder source_folder
		repeat with currFile in kFiles
			set this_file to currFile
			
			copy the name of this_file to originalname
			-- display dialog "The filename is: " & (originalname as string)
			
			tell application "Finder"
				copy the name of this_file to originalname
				open this_file
				set name of contents of this_file to originalname				
			end tell			
		end repeat
	on error error_message
		display dialog error_message
	end try
end tell