Copy link to clipboard
Copied
HI All,
I need a help for the below request.
1. User has to place the files in the "IN" Folder like "test.txt"
2. AppleScript want to move to "OUT" Folder with rename of "err_text.txt"
For your better understanding,
Thanks
SS
Copy link to clipboard
Copied
You would use the Finder to move the file and rename it:
tell application "Finder"
--the path to the file to move
set dt to path to desktop
set mf to dt & "Test:IN:test.txt" as string
--the move file’s name
set fn to name of file mf
--the destination folder
set df to dt & "Test:OUT:" as string
--move the file to the destination folder
set ef to move file mf to folder df
--change the moved file‘s name
set name of ef to "err_" & fn
end tell
Copy link to clipboard
Copied
Try this code snippet:
tell application "Finder"
set theFile to file "test.txt"
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
try
set fileName to name of theFile
set nameWithoutExtension to first text item of fileName
set name of theFile to "err_test.txt"
set AppleScript's text item delimiters to oldDelims
move POSIX file "/Users/xx/In/err_test.txt" to POSIX file "/Users/xx/Out/" with replacing
on error
set AppleScript's text item delimiters to oldDelims
end try
end tell
Best
Sunil