I want to add a bit of text to end of a filename in a folder action, before the file extension. the same piece of text to all files. Problem is the finder just repeats it constantly as it sees each change as a new file and just keeps on adding the text.
Would it be possible to have a script add the text to a file, then move it to another folder in one script? This way avoiding the loop problem?
Model: MacBook 1.83GHz
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)
Yes, you can move the file or, you could test to see if the extension already exists.
Rightio at least I know it’s worth figuring it out, it would suit me more to move the file at the end of the script so I’m gonna head down that route. Wish me luck!
Model: MacBook 1.83GHz
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)
OK I tried to bodge together some scripts, but it doesn’t work (surprise!). Any pointers? It moves the files no problem, I tried to tweak the Applescript that lets you add text to a file, but I wanted it automated instead of with a dialogue box.
on adding folder items to this_folder after receiving these_items
set the the_new_text to "_LR"
set the item_list to list folder this_folder without invisibles
set this_folder to this_folder as string
repeat with i from 1 to number of items in the item_list
set this_item to item i of the item_list
set this_item to (this_folder & this_item) as alias
set this_info to info for this_item
set the current_name to the name of this_info
if folder of this_info is false and ¬
alias of this_info is false then
set default_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
set the_root_name to the first text item of the current_name
set the_suffix_name to the last text item of the current_name
set the new_file_name to the (the the_root_name & the the_new_text & "." & the the_suffix_name) as string
set AppleScript's text item delimiters to default_delimiters
end if
tell application "Finder"
move this_item to "Magic Tree:Users:liam:Desktop:Test"
end tell
end repeat
end adding folder items to
Model: MacBook 1.83GHz
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)
try this
on adding folder items to this_folder after receiving these_items
set the the_new_text to "_LR"
repeat with oneItem in these_items
set {name:Nm, name extension:Ex} to (info for oneItem)
if Ex is missing value then set Ex to ""
if Ex is not "" then
set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
set Ex to "." & Ex
end if
set destinationPath to quoted form of (POSIX path of (path to desktop) & "Test/" & Nm & the_new_text & Ex)
do shell script "/bin/mv " & quoted form of POSIX path of oneItem & space & destinationPath
end repeat
end adding folder items to
Fair enough! Thank you, I am determined to learn Applescript now. It’s so bloody useful!
Model: MacBook 1.83GHz
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)