0

I've inherited some shell scripts that trigger via Launch Control for OSX. I'm trying to add a script of my own that - whenever a folder is added to a specific directory - will rename the files inside those folders based on specific criteria.

As examples, I need the following renames to occur whenever necessary:

123456_LK.tif = 123456_standard.tif

123456_ALT1.tif = 123456_alternate1.tif

The problem is that I have a script that will perform this renaming if I run it in Terminal, but in Launch Control is just won't work. Does anyone have any experience using this app? I've copied the current entries in the app that work and have just targeted my own script but I can't get it to work.

Here is the line that renames the standard files:

#!/bin/bash find /Volumes/COMMON-LIC-PHOTO/ASPERA/ASPERA_STAGING -mindepth 2 -type f -exec rename -v 's/([0-9]*)_LK/$1_standard/' \;

In Launch Control the entry status is OK and returns no errors, and yet the files do not get renamed. I've tried using rename (which I don't think is supported) and mv - neither work in the various ways I tried them,

James Trory
  • 121
  • 1
  • 2
  • 7
  • I'm guessing you are on a Mac and have installed `rename` using **homebrew**? You probably need to use the full path `/usr/local/bin/rename` – Mark Setchell Jul 17 '17 at 22:28
  • Else run `which rename` to find the full path. – Mark Setchell Jul 17 '17 at 22:29
  • I looked it up with `which rename` but using the full path doesn't work either. – James Trory Jul 17 '17 at 22:52
  • It really doesn't make sense that the script would run in Terminal but not in Launch Control. Makes me think I've set up LC wrong but I don't know what the problem would be since it doesn't give me any error messages. – James Trory Jul 17 '17 at 22:58
  • These issues often occur with `cron` jobs (Stack Overflow is littered with questions about why scripts work in Terminal but not in `cron`) and the answer is generally that the environment is different - most likely the PATH. – Mark Setchell Jul 17 '17 at 23:04
  • @MarkSetchell I'll have a look at `cron` solutions then, maybe that's the root problem. I'm not very familiar with using tools like Launch Control anyway so it'll be good research. Thanks. – James Trory Jul 18 '17 at 18:12
  • It works now, I don't think I was using the rename path correctly. New problem is that the script starts to rename the files immediately, before they've finished copying to ASPERA_STAGING. It's causing the computer to copy files over twice. Is there a way to add a check to the script so that it waits until the copy is finished? – James Trory Jul 18 '17 at 21:07

0 Answers0