upgraded to Hi Sierra :-(

Hi All!

I upgraded my OS and now I have a problem with “tmpfile” which seemed to work previously…

Heres an example:

do shell script "sed -e 's/%20/_/g' /Users/snaplash/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt > tmpfile; mv tmpfile /Users/snaplash/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt"

I get an error of mv tmpfile: No such file or directory in the log history. Does this new OS require specific destination to overwrite original file?

Does anyone have any idea what needs to happen? I have been out of the loop for a while and am a bit rusty on applescript

Thank you!

I can confirm that there’s a permission problem with tmpfile when using your script with a file and folder set up on my own High Sierra machine; but never having used tmpfile before, I don’t know if this is something new.

sed itself will edit files in place if you use its -i option with a zero-length extension:

do shell script "sed -e 's/%20/_/g' -i '' /Users/snaplash/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt"

But the sed manual recommends not doing this in case of corruption. Instead, use -i with a proper extension. The original file will be preserved with the new extension tagged onto the end of its name and the edited text will be written to a new file with the original name in the same folder. You can then delete the original file if desired:

do shell script "sed -e 's/%20/_/g' -i '.bak' /Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt ; rm /Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt.bak"

It’s also a good idea to quote paths and other parameters used in shell scripts. So:

do shell script "sed -e 's/%20/_/g' -i '.bak' " & (quoted form of "/Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt") & " ; rm " & (quoted form of "/Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt.bak")

Nigel,

Thank you so much for your response! I implemented it with success!

However, like an ungrateful XXXX I forgot to, and didnt respond. :slight_smile: I just remembered why my program is running flawlessly and it was because of you!

Happy New Year and Thanks for all of your hard work and dedication!

A little tipsy as its New Years!

Thanks Nigel!