Hello can someone please help me. The following code should simply replace the word “Volumes” with “/RAID/Data” and then spit out a revised list of file paths only I can’t for the life of me get it to work!!!
set incorrectfilepaths to {“/Volumes/SHARE/Artwork/extra_special.jpg”, “/Volumes/SHARE/Artwork/james.jpg”}
set Volumes to “Volumes”
set rAIDData to “RAID/Data”
set finalPath to {}
repeat with eachItem in incorrectfilepaths
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to Volumes
set correctPath to every item of incorrectfilepaths
set AppleScript's text item delimiters to rAIDData
set correctPath to correctPath as text
set newText to finalPath
set AppleScript's text item delimiters to OldDelims
end repeat
Any help would be great I have a long night ahead
cheers
J :shock:
set incorrectFilePaths to {"/Volumes/SHARE/Artwork/extra_special.jpg", "/Volumes/SHARE/Artwork/james.jpg"}
set Volumes to "Volumes"
set rAIDData to "RAID/Data"
set correctPaths to SwapDelimsInEach(incorrectFilePaths, Volumes, rAIDData)
--
--> {"/RAID/Data/SHARE/Artwork/extra_special.jpg", "/RAID/Data/SHARE/Artwork/james.jpg"}
on SwapDelimsInEach(a, f, r)
copy a to a -- don't data-share with orig list
set tids to AppleScript's text item delimiters -- save
repeat with i from 1 to a's length
set s to a's item i
set AppleScript's text item delimiters to f
set s to s's text items
set AppleScript's text item delimiters to r
set s to s as string
set a's item i to s
end repeat
set AppleScript's text item delimiters to tids
return a
end SwapDelimsInEach
Hope your folders/filename don’t contain “Volumes”.
Consider this:
set incorrectPathList to {"/Volumes/SHARE/Artwork/extra_special.jpg", "/Volumes/SHARE/Artwork/james.jpg"}
set correctPathList to {}
repeat with thisItem in incorrectPathList
if thisItem starts with "/Volumes/" then set thisItem to "/RAID/Data/" & text 10 thru -1 of thisItem
set correctPathList's end to thisItem
end repeat
correctPathList