Hi all,
I have a folder action script that trims the first part of a files name then moves that file.
The overall lenght of the names will differ, but will always begin with an underscore then an alphanumeric code then underscore:- eg. _1A2B3_THE_FILE_NAME_PAGENUMBER.pdf
This works fine so long as I get the finder to display the variable ‘totCnt’
As soon as I comment out (as in the following script) or remove completely the line
the first file seems to get trimmed twice (or more than I intend) ???!!!
Can anyone spot what I am doing wrong?
Script –
on folderReady(theFolder)
set myFolder to theFolder as alias
set firstSize to size of (info for myFolder)
delay 1
set newSize to size of (info for myFolder)
repeat while newSize ≠firstSize
set firstSize to newSize
delay 1
set newSize to size of (info for myFolder)
end repeat
return true
end folderReady
on adding folder items to thisFolder after receiving theseItems
if folderReady(thisFolder) then
set finalFolder to alias "Macintosh HD:Users:tcuser35:Desktop:my test workflow:final folder:"
set logFile to alias "Macintosh HD:Users:tcuser35:Desktop:my test workflow:log file.txt"
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "_"
tell application "Finder"
repeat with thisItem in theseItems
try
set theName to name of thisItem
set itemParts to every text item of theName as list
set totCnt to (count of itemParts) as integer
set newName to text items 3 thru totCnt of itemParts as string
on error errText number errNum
display dialog "" & errText & return & errNum & ""
end try
tell application "Finder"
-- display dialog "Text parts: " & totCnt & ""
set name of thisItem to newName
move thisItem to finalFolder with replacing
end tell
end repeat
end tell
end if
set AppleScript's text item delimiters to oldTIDs
end adding folder items to
Any thoughts greatly appreciated.