Sample Header Ad - 728x90

change mutiple xml fields data and the data have differnt name #have try apple script #on mac

2 votes
1 answer
103 views
### Scenario description This side needs to go to a ftp regularly to download the data down and change their fields. The process is: 1. Download from a place to get a file name called "202301081014XXXX.REQ" data format xml 2. change the data of one of the fields of S001 which content is "1234" Change it to "abcd" 3. If the change is completed, create a file with the same name and name it as "202301081014XXXX.REQ.OK" 4.Upload the two created data to another ftp path Currently I have tried the action 1. via Mac app script tools 2. The operation of recording the screen is as follows
tell application "Finder"
    activate
    open document file "202301081014N1234.REQ" of folder "Downloads" of folder "blue2" of folder "Users" of startup disk using application file "BBEdit.app" of folder "Applications" of startup disk
end tell
tell application "BBEdit"
    activate
    open find window
    find "1234" searching in text 1 of text document id 829 with selecting match
    set characters 406 thru 428 of text document id 829 to "abcd"
    select insertion point after characters 406 thru 428 of text document id 829
    save text document id 829
end tell
### Problems encountered Because the names of the data are different, I have read the [official documents](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_folder_actions.html#//apple_ref/doc/uid/TP40000983-CH219-SW2) but I don't know how to define the scope. And the \ field is in a different position, so I can't execute the recorded AppleScript.
Asked by blue2lynn (21 rep)
Jan 8, 2023, 02:27 PM
Last activity: Sep 30, 2024, 11:04 PM