Hi Everybody,
I am newbie to script, I need a script it may be a droplet or choose file type or Folder Action, what ever it may be I want to do the script should Rename the file and move to the Host/Local Server.
Please do let me know if anyone aware of this…hope you people may rocks!!!..
These are the steps I want to do:
- Choose file type are “PDF” and “HTML” it should be multiple files. (If it is great both should be Zipped after rename but its a optional).
 - Then get the info from the user add after the underscore “_” in the original file name the extension remains same. (For eg. 10-1234-1_C10.1.pdf")
 - Then the renamed file should moved to the Host Server.
 - If the Host server is not exist, show the alert and connect automatically get the login info from user.
 - At the same time one copy should be move to local server the original file should be deleted after moved.
 - Before move to the Host server, match the folder name between Host and original source folder if both matches then the file should be moved.
 
I have wrote a code as attached but it not works fine.
tell application "Finder"
	
	choose file of type {"com.adobe.pdf"} with prompt "Choose the PDF"
	set theFiles to result
	set org to name of theFiles
	set source_folder to (name of theFiles) as string
	set file_path to (source_folder as string) as string
	set file_name to file_path as string
	set jobNumber to (characters 1 thru ((offset of "_" in file_name) - 1) of file_name) as text
	
	set dt to current date
	set m to month of dt as text
	set m to text 1 thru 3 of m
	set d to day of dt as text
	set y to year of dt as text
	set yr to text 3 thru 4 of y
	set mydate to (d & "-" & m & "-" & yr) as text
	
	
	
	set loginID to short user name of (system info)
	
	-- We have to enter manually the Drop Cycle number
	set cycle to display dialog "Enter the Cycle.Drop number (Only separated by Hyphen)" default answer "."
	set the drop to the text returned of the result as string
	
	
	-- Finder will change the file name
	tell application "Finder" to set name of theFiles to (jobNumber & "_" & "C" & drop & ".pdf")
end tell
set x to name of theFiles as text
display alert x buttons {"Quit", "Continue"} default button 2
if button returned of result is "Continue" then
	
	--To move the file with proper naming standard to the TRAINING server
	
	
	tell application "Finder"
		set mounted_Disks to list disks
		--display dialog result as string
		--set mounted_Disks to every disk whose (ejectable is true)
		
		if mounted_Disks does not contain "Training" then
			mount volume "afp://afp://xxxxxxxxxxxxxxxx/Training[b](Local Server[/b]" as user name "username" with password "password"
		end if
		
		try
			set Train to mount volume "afp://xxxxxxxxxxxxxxxx/Training[b](Local Server[/b])"
		end try
		
		set dt to current date
		set m to month of dt as text
		set w to text of m
		set m to text 1 thru 3 of m
		set d to day of dt as text
		set y to year of dt as text
		set mymonth to (w & " " & "Files") as text
		set mydate to (d & "-" & m & "-" & y) as text
		set myyear to y as text
		
		set sampleAudit to (("Training" as string) & "CHE" as alias)
		set create_month to ((((sampleAudit as string) & myyear as alias) & mymonth as alias))
		
		if (not (exists folder ((create_month as string) & (mydate as string)))) then
			make folder at create_month with properties {name:mydate}
			set mainFolder to ((Train as string) & "CHE" as alias)
			set create_month to ((mainFolder as string) & mymonth as alias)
			set targetFolder to ((create_month as string) & mydate as alias)
			move theFiles to targetFolder
			display alert "Copy of the file also moved in to the Training server"
			
		else
			set mainFolder to (("Training" as string) & "CHE" as alias)
			set create_month to ((mainFolder as string) & mymonth as alias)
			set targetFolder to ((create_month as string) & mydate as alias)
			
			move theFiles to targetFolder
			
			set ZZ to name of theFiles
			set YY to modification date of the files of targetFolder
			display alert "Copy of the file has been moved to the Local Training Server"
		end if
	end tell
	
	--To move the file with proper naming standard to the HOST Server
	
	try
		tell application "System Events"
			set UserName to name of current user
		end tell
	on error
		set UserName to display dialog "Please enter your User ID." with icon note default answer "" giving up after 15
		set UserName to text returned of UserName
	end try
	
	set mounted_Disks to list disks
	
	if mounted_Disks does not contain "Training" then
		
		try
			with timeout of 3600 seconds
				mount volume "afp://afp://xxxxxxxxxxxxxxxx/[b](HOST Server[/b]" as user name UserName
			end timeout
			
		on error
			set name of theFiles to org
			error "You have canceled login."
			
			--exit repeat
		end try
	end if
	
	try
		set TheServer to mount volume "aafp://xxxxxxxxxxxxxxxx/[b](HOST Server[/b]"
	end try
	
	
	set step1 to ((TheServer as string) & "CHE" as alias)
	set step2 to ((step1 as string) & "SUB Folder" as alias)
	set step3 to ((step2 as string) & "PERIODIC DATE" as alias)
	set destination to ((step2 as string) & loginID as alias)
	move theFiles to destination
	
	delete theFiles
	
else
	set name of theFiles to org
	
	display alert "Oops......your file name may be wrong please enter the correct Input again"
end if
--eject "ED_Transfer"