Jump to content

dash86

Members
  • Content Count

    2
  • Joined

  • Last visited

About dash86

  • Rank
    InsanelyMac Protégé
  1. dash86

    Search and replace file name

    thx I will try it out
  2. Hi, I need a hint. Problem to solve is user inputs a number. Number is being searched in a folder (2015) with one already existing folder named with the same number user inputs. lets say user searches for 123456 folder being searched is 2015 and folder to be found is 123456-CPY, Now the script needs to replace CPY with OK. Files have different legth say the name can be 123456-CPY or the name can be 123456-ToDo-KD-CPY In the folder of 2015 I have backups named 123456 or 123457 or 123458 all have different file names like so: 123456-Todo-KD-CPY 123457-done-KD-CPY 123458-CPY 123459-NEW-CPY If I am done I just want the CPY changed to OK. I am only searching for the 6 numbers in front so i only type in 123456 but the folder to be renamed could have the extension "done-KD-CPY" or "NEW-CPY" but not both together the number up front is unique. For example I am looking for 221334 in the script (one hit): folder 221334-done-KD-CPY now the name needs to be 221334-done-KD-OK. Hope this explains it better and helps. I would appreciate if you could help out. set theReturnedItems to (display dialog "Type Number plz" & return & return & "Number: " default answer "123456") set numberip to the text returned of theReturnedItems set pfad to (choose folder) tell application "Finder" set numberip2 to name of folder (pfad & numberip) end tell rename(numberip2, "ö|CPY| B", "oe|OK|B", "|") on rename(input, srchList, replList, separator) if class of srchList is string then set AppleScript's text item delimiters to separator set srchList to every text item of srchList set replList to every text item of replList else set AppleScript's text item delimiters to "" end if repeat with i from 1 to (count of srchList) set srch to item i of srchList set repl to item i of replList set AppleScript's text item delimiters to srch set the temp to every text item of input set AppleScript's text item delimiters to repl set input to temp as string end repeat set AppleScript's text item delimiters to "" return input end rename
×