Renaming Script Help

Joined
Jun 2, 2011
Messages
2
Reaction score
0
Points
1
I have a script I wrote... I pretty much know nothing about apple script and was just piecing it together with help from friends.

Im getting an error when I use it on a FAT drive... gives me an Alias problem.

O1spe.png



Here is the script... any help would be GREATLY appreciated.

Code:
display dialog "Change Suffix to First Two Characters of File Name:" buttons {"Send The Pids!", "Cancel"}

set myfolder to characters 1 through -2 of (POSIX path of ((choose folder) as alias)) as text

set foundfiles to every paragraph of (do shell script "find " & quoted form of myfolder & " -type f -iname \"*.wav\"")

repeat with afile in foundfiles
	
	set afile to ((afile as text) as POSIX file as alias)
	
	tell application "Finder"
		
		set filename to name of afile
		
		set filesuffix to (characters -4 through -1 of filename) as text
		
		set addonsuffix to characters 1 through 2 of filename
		
		set filename to (characters 1 through -5 of filename) as text
		
		set newfilename to filename & "_" & addonsuffix & filesuffix
		
		set name of afile to newfilename
		
	end tell
	
end repeat
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Hi Cameron

In short your Applescript is a mess.

Your problem is not the Fact that you're trying to access a FAT drive, but that your trying to coerce POSIX files types to alias's in one line of code, and also trying to coerce text types to POSIX types to alias types in one line.
also you have not implemented any kind of error checking into your script.

Tell me what you are trying to achieve with this Applescript, and I will guide you through the required Applescript code, to achieve your goals.

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top